• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Attaching a special effect on a unit (without leaks)

Status
Not open for further replies.
Level 12
Joined
Jan 4, 2014
Messages
543
Hi,
I'm creating a custom ability, which uses Bladestorm as its foundation. As such i want to attach a special effect on the casting unit for a set amount of time. Unfortunately the simple attach special effect to unit + wait + destroy last special effect combination causes massive memory leaks.

I have been following this awesome tutorial, but it only shows to to place a special effect at the position of unit, but doesn't show how to attach it on to the unit.
http://www.hiveworkshop.com/forums/...ial-effects-manipulation-modification-168560/

Is there any way i can attach a special effect on to a unit for a set amount of time and make it not leak?

This is what i got so far, but it does not attach the special effect.
Fzz1vvL

http://imgur.com/Fzz1vvL
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Never use "Wait ... seconds".
That action does not know if the game is paused or not.
So if you activate a 30 seconds wait and you pause the game for 30 seconds, you will see that that timer has expired when you unpause the game.
It also does not see how fast the game runs.
That action waits ... seconds of real life time. (not even accurate)
"Wait ... seconds of gametime" on the other hand does calculate in game time so that one is thousand times better... except that it leaks.
So you go to the header file. (At the top of the trigger list is a blue map icon with the name of the map, click on it and you see a text editor which colors the text you write.)
And paste this stuff in it.
JASS:
function GameTimeWait takes real duration returns nothing
    local timer t
    local real  timeRemaining

    if duration > 0 then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining <= 0
            
            if timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
        set t = null
    endif
endfunction

When you want to wait ... time, you do this:
  • Custom script: call GameTimeWait(2)
But to the point of adding the attachment.
There is an action just below the one, you use.
  • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
That one creates an attachment to a unit.
You can see that the location is replaced by a unit variable and that there is a new field.
That new field is the attachment point.
Attachment points are points on a model that you can attach special effects to. (Some other things as well but that doesnt matter right now.)
At the bottom of this page is a list of all (at least most) attachment points of most standard models.
Choose one that you like.

Further about your trigger.
I think you want to use the event "A unit starts the effect of an ability" (generic unit)
There are 2 differences:
1. It now works for every unit that casts that ability.
2. It now starts the effect when the ability is turned on cooldown and the mana cost is taken.
With your event, you can begin casting and then cancel the cast and still have that 100 damage without that the ability is on cooldown or using mana.
Also, you dont have to wait before removing the location.

Last but not least... I personally made a system that can attach special effects, give abilities, add buffs, create effects on interval and control them alltogether for the use in GUI.

The difference between your trigger modified by everything above and using that system is that your trigger will be accurate to 0-0.167 seconds (meaning that it can end 0 seconds before to up to 0.167 seconds after you wanted it to end) and mine is 0-0.02 seconds accurate... which is good enough for the human eye.
It also makes this spell MUI, so all units on the map can cast it and it works for each and every unit with their own duration.
That system is my Effect Over Time System.
When you use that one, your trigger will be exaclty this:
  • Wrath of the Lich King
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Wrath of the Lich King
    • Actions
      • Custom script: call EOT_Set_Default_Variables()
      • Set EOT_Param_Source = (Triggering unit)
      • Set EOT_Param_Target = EOT_Param_Source
      • Set EOT_Param_Duration = 4.00
      • Set EOT_Param_Hidden = True
      • Set EOT_Param_Can_Dispell = False
      • Set EOT_Param_Special_Effect_Point = chest
      • Set EOT_Param_Special_Effect_Model = war3mapImported\DarkHarvest.mdx
      • Set EOT_Param_Ability = Add DMG (+100)
      • Set TempAbility = (Ability being cast)
      • Custom script: set udg_TempInteger = udg_TempAbility
      • Set EOT_Param_Type = TempInteger
      • Set EOT_Param_Positive = True
      • Trigger - Run EOT_Trigger_Create_EOT (ignoring conditions)
Choose what fits you most.
 
Status
Not open for further replies.
Top