• 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.

Changing Effect Durations

Status
Not open for further replies.
Level 2
Joined
Oct 18, 2011
Messages
16
Is there a way to change the duration of a buff/effect for an ability? I am trying to create an Unholy Frenzy that changes duration based on the amount of charges in an item that a hero is carrying. Thank you.

P.S. I've had no luck with Google to find the answer.
 
Level 12
Joined
Oct 16, 2010
Messages
680
well i think the only way is.. U make that much different ability with different durations how much the item can be stacked

or trigger the spell by yourself
basically this would be the better option
i think it can be done easily by setting the ebility max level to how much the item can stack and when used
check the number of stacks .. and use the ability with that level on the unit with a dummyunit
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Some abilities get 'infinite' duration when it's set to '0'. If not, you can place "9999" duration (about three hours).

This way, you work the 'Effect' Removal, instead of the 'Effect' Duration.
"Effect lasts 20 seconds" = "Effect is removed after 20 seconds". It's the same, but from a different perspective.
 
Level 8
Joined
Jan 8, 2008
Messages
454
Why not just make it so when this 'Unholy Frenzy' is cast, the buff/ability just replays again? You could have it manually done so you copy-paste this buff/ability "x" amount of times, each copy-pasted buff/ability having a different time taken to cast and when you cast unholy frenzy, if you have "x" charges in your inventory then cast buff "x" on unit "x". Something like that is all I can think off at the top of my head without WEditor xD

Hope it helps.
 
Level 2
Joined
Oct 18, 2011
Messages
16
Hmm this seems like useful information, thank you all.

@Spartipilo: What is this "Effect Removal" thing anyway, based on what I have read it sounds like the trigger "Remove Buff of Type."

@Levdragon: Are you saying that a Dummy should recast Unholy Frenzy on the target?

So far I have this idea after reading the posts:
Set Unholy Frenzy to the max duration (lets just say 20 for example).
Create a trigger that removes the Unholy Frenzy buff based on the charges of said item.
The variable could be.... "DurationFrenzy" equal to Charge*4. The trigger could look like something like this:
If triggering unit has greater than 0 Charges then,
Wait "DurationFrenzy" seconds.
Remove buff from targeted unit of type Unholy Frenzy.

How does that sound to you all?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Good, but not the "Wait" part. The "Wait" action is mean and evil :p Try not to use it. Timers are used for this. I don't know precisely how to work timers for units the way you want to, but I'm sure there are a lot of resources around for that. Basically, you have to start a timer with the Charges * 4 duration, and remove the buff when timer expires.

The next method will require a Unit Indexing System (Bribe has a good one in Spell Section)

An "easy" way to do it is with a loop.

1) Create a Unit Group called whatever you want (I'll call it "UnholyGroup"). Also create a "Integer Array" for the loop, and "Integer Array" for the time limit.

2) Create a Trigger that adds the casting unit to UnholyGroup when casts the skill and
set TimeLimit[Custom Value of Casting Unit] = Charges on item * 4.

3) Create a Trigger that every 1 sec (If number of units in UnholyGroup > 0) picks every unit in UnholyGroup and

set Int_Timer[Custom Value of Picked Unit] = Int_Timer[Custom Value of Picked Unit] + 1.
Create an If/Then/Else, and
JASS:
if Int_Timer[Custom Value of Picked Unit] = TimeLimit[Custom Value of Casting Unit] or Unit has "Unholy Frenzy" buff = False then
    Set TimeLimit[Custom Value of Casting Unit] = 0, and remove the unit from UnholyGroup.

There's another way using Hashtables, but is almost the same. Instead of using Custom Value of Unit, can use Unit ID, and works for infinite unit (If you plan to use this for over 8190 units at the same time).

Using "Number of charged greater than 0" means the unit has the item. Item with 0 charges is empty slot.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Huh? What's the problem with several systems working with the unit custom value? They don't change it, just takes it to know which unit is.... Some kind of Unit Id replacement.
 
Level 4
Joined
Oct 20, 2011
Messages
129
Make a Buff/Effect system. I already have one:
  • StunnedLoop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Stunned and do (Actions)
        • Loop - Actions
          • Hashtable - Save Handle Of(Picked unit) as (Key TempUnit) of 1 in HASHTABLE
          • Set TempReal = (Load (Key StunnedTime) of (Key (Load (Key TempUnit) of 1 in HASHTABLE)) from HASHTABLE)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempReal Greater than 0.00
            • Then - Actions
              • Set TempReal = (TempReal - 0.03)
              • Hashtable - Save TempReal as (Key StunnedTime) of (Key (Load (Key TempUnit) of 1 in HASHTABLE)) in HASHTABLE
            • Else - Actions
              • Hashtable - Save 0.00 as (Key StunnedTime) of (Key (Load (Key TempUnit) of 1 in HASHTABLE)) in HASHTABLE
              • Unit - Remove Stunned (Pause) buff from (Load (Key TempUnit) of 1 in HASHTABLE)
              • Unit Group - Remove (Picked unit) from Stunned
            • Hashtable - Clear all child hashtables of child 1 in HASHTABLE
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Stunned) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
It's for stunned and I made it in 5 minutes (Maybe can cause error). You can change it a little to have a completed system.
 
Level 2
Joined
Oct 18, 2011
Messages
16
Well thats a ton of information that is new to me so I'll have to learn more about these custom values and hash tables. I tried the trigger I made in my earlier post and it WOULD HAVE worked if it weren't for the "Wait" trigger. I'm guessing that "Wait" uses only absolute values (for lack of better word) and no mathematical equations such as (Charge*4). Because then the "Wait" trigger just assumes that you want the trigger to last 0 seconds. It literally get rids of the buff right away.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Oh.. wait can use any real value (decimals). The thing is that "wait" stops all the trigger actions, and, afak, it runs even when game is paused.

I can give you a MUI example using hashtables.
 
Status
Not open for further replies.
Top