• 🏆 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!

[Trigger] Custom scripts

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2012
Messages
158
Hello hive members.
I have just started working with custom scripts and I can't get this one to work. It's a spell that is supposed to summon a black hole 700yards (or what it is) behind the targeted unit. It will start dragging him towards it, but he can flee from it untill the duration ends up.
But my problem is that he is locked in the drag point. He uses his run animation but cannot walk away from it, if you know what it mean :)
Here it is:
  • Black Hole
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Black Hole
    • Actions
      • Set BlackHoleCaster = (Triggering unit)
      • Set BlackHoleTarget = (Target unit of ability being cast)
      • Set BlackHoleTargedPoint = (Position of BlackHoleTarget)
      • Set BlackHolePoint = (BlackHoleTargedPoint offset by 700.00 towards ((Facing of BlackHoleTarget) - 180.00) degrees)
      • Set BlackHole_Distance = 30
      • Special Effect - Create a special effect at BlackHolePoint using BlackHoleSpell.mdx
      • Set TheBlackHole = (Last created special effect)
      • Unit - Turn collision for BlackHoleTarget Off
      • Lightning - Create a Drain Life lightning effect from source BlackHolePoint to target BlackHoleTargedPoint
      • Set BlackHoleEffect = (Last created lightning effect)
      • Trigger - Turn on Black Hole Loop <gen>
      • Wait 10.00 seconds
      • Trigger - Turn off Black Hole Loop <gen>
      • Special Effect - Create a special effect at BlackHolePoint using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_BlackHoleTargedPoint)
      • Custom script: call RemoveLocation(udg_BlackHolePoint)
      • Custom script: call RemoveLocation(udg_BlackHoleDrag)
      • Lightning - Destroy BlackHoleEffect
      • Special Effect - Destroy TheBlackHole
  • Black Hole Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Distance between BlackHoleTargedPoint and BlackHolePoint))) Greater than BlackHole_Distance
        • Then - Actions
          • Set BlackHoleDrag = (BlackHoleTargedPoint offset by 5.00 towards (Angle from BlackHoleTargedPoint to BlackHolePoint) degrees)
          • Custom script: call SetUnitX(udg_BlackHoleTarget,GetLocationX(udg_BlackHoleDrag))
          • Custom script: call SetUnitY(udg_BlackHoleTarget,GetLocationY(udg_BlackHoleDrag))
          • Set BlackHoleTargedPoint = (Position of BlackHoleTarget)
          • Lightning - Move BlackHoleEffect to source BlackHolePoint and target BlackHoleTargedPoint
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Unit - Kill BlackHoleTarget
          • Special Effect - Create a special effect at BlackHolePoint using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_BlackHoleTargedPoint)
          • Custom script: call RemoveLocation(udg_BlackHolePoint)
          • Custom script: call RemoveLocation(udg_BlackHoleDrag)
          • Lightning - Destroy BlackHoleEffect
          • Special Effect - Destroy TheBlackHole
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
You must know this ability isn't MUI. It can be cast only once per unit in the map. If another unit casts it while the first one is being cast, it will bug, malfunction, and leak a lot. Even if it's going to be cast by a boss or something, making it MUI is commonly making it efficient.

The drag speed (The velocity the unit is sucked into the Black Hole) has to be lower than the unit movement speed in order for the unit to move away faster than it's sucked in. Your offset is equal to 100 per second, which is good and your unit should be able to escape.
 
Level 7
Joined
Jul 9, 2012
Messages
158
Thanks for your response :)
Yeah, it is a boss fight, but I have setted the cooldown of the dummy ability (the one who starts the trigger) to be much longer than the maximum duration of the trigger. Is it still a problem then?

The use of my custom scipts just made him to use the walk animation etc. when I try escaping, but it's like using "Move Instantly". He cannot move away from the point. :)
 
Well all I could really suggest, would be that your drag strength is too strong for your unit to be able to pull away from, thus can't escape, assuming that, that is the case and your unit should be fully able to pull away, I would suggest not using GetLocationX/Y and find the X/Ys yourself using mathematical formula which'd look as follows:

  • Custom script: call SetUnitX(udg_BlackHoleTarget, GetUnitX(udg_BlackHoleTarget) + 5.00 * Cos(udg_Angle * bj_DEGTORAD))
  • Custom script: call SetUnitY(udg_BlackHoleTarget, GetUnitY(udg_BlackHoleTarget) + 5.00 * Sin(udg_Angle * bj_DEGTORAD))
I'm using udg_Angle because It's more efficient to store the angle in a variable when I'm going to be using it twice, really the distance (5.00) should also be stored in a variable but this was for making it more readable in this instance

If doing that still does not get it to work, then all I could say is the problem is not in the custom scripts.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
As long as the ability isn't cast twice at the same time, and any of the involved variables isn't used during the cast of the ability, there should be no problem.

I would, in fact, convert everything to custom script, remove all the bj's, and work with locals.
 
Status
Not open for further replies.
Top