Help with a knockback spell?

Tarivol

New Member
Reaction score
2
Trigger:
  • Combat Knife
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Com|cffffcc00b|rat Knife (Neutral Hostile)
    • Actions
      • Set KnockTo = ((Position of (Target unit of ability being cast)) offset by 500.00 towards (Angle from (Position of (Casting unit)) to (Position of (Target unit of ability being cast))) degrees)
      • For each (Integer A) from 1 to 100, do (Actions)
        • Loop - Actions
          • Set MoveTo = ((Target point of ability being cast) offset by 3.00 towards (Angle from (Position of (Target unit of issued order)) to KnockTo) degrees)
          • Wait 0.01 seconds
          • Unit - Move (Target unit of ability being cast) instantly to MoveTo


So, I'm a little confused by what's going on with this trigger; Notably, this isn't something I came up with, it's something I saw in a tutorial on youtube.

First off, I'm not entirely sure I understand what exactly is going on with the trigger; for example, why is knockto being set with a 500 offset? If anyone can explain the laymens terms happenings behind this trigger, that would be much appreciated..

And second off, the trigger isn't doing what I want it to. Basically, it's supposed to move the unit back, in a slide, 300 units; Instead, it seems like only the bash portion is reliable, as it's based on firebolt (neutral hostile). Is the base spell causing the problem? The cast range for the ability is 200, it has no cast time.. The above trigger seemed to work fine for the guy who posted the tutorial, but when I test it, it seems to sometimes teleport the unit it targets a small distance, and that's only sometimes.

Can anyone give me some insight?
 

Tarivol

New Member
Reaction score
2
Alright, so, after talking the trigger out to my wife, who tolerates my insanity, I've come up with the following logic;

When a unit finishes casting the spell,

set the variable knockto = a point, along a line drawn from the caster, to the target, 500 units behind it,

count from 1 to 100, and at each number along the way,

set moveto = 3 units behind where the unit currently is, towards knockto

wait for a hundredth of a second

move the unit there.

After some reviewing of the trigger on my own, I've edited it to look like this;

Trigger:
  • Combat Knife
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Com|cffffcc00b|rat Knife (Neutral Hostile)
    • Actions
      • Set KnockTo = ((Position of (Target unit of ability being cast)) offset by 500.00 towards (Angle from (Position of (Casting unit)) to (Position of (Target unit of ability being cast))) degrees)
      • For each (Integer A) from 1 to 100, do (Actions)
        • Loop - Actions
          • Set MoveTo = ((Position of (Target unit of ability being cast)) offset by 3.00 towards (Angle from (Position of (Target unit of ability being cast)) to KnockTo) degrees)
          • Wait 0.01 seconds
          • Unit - Move (Target unit of ability being cast) instantly to MoveTo


But it's still not doing what I want it to.
 

NoobImbaPro

You can change this now in User CP.
Reaction score
60
remove the wait action. And set the event to "Starts an effect of an ability".
It should work.
 

Tarivol

New Member
Reaction score
2
Three things, in response; well, four

first, thank you for replying ^^

Second, I thought we picked 'finishes casting a spell' in order to keep people from stopcast abusing trigger enhanced spells?

Third, do I have the logic of the spell more or less correct?

And four, why is the wait messing it up?
 

Ayanami

칼리
Reaction score
288
Nope, Starts an effect on an ability event triggers when the spell is actually cast. So it can't be spammed. "Begins casting an ability" is the event that can be spammed.

Okay about your trigger. Using waits inside loops are bad. It screws up all the same integer loops that are running in your map. Basically, what your trigger does is that it moves the unit by 3 distance every 0.01 seconds for 100 times. So it would finally result in 300 distance over 1 second.

My suggestion to you is that you don't use loops. Create a periodic trigger that moves the unit. If you need help with this, I'll be glad to help you out.
 

Tarivol

New Member
Reaction score
2
I would love it if you could present an idea about how to do so; I'm incredibly new to warcraft mapmaking, and while the triggers seem at least partially intuitive, I'm being halted by a lack of knowing what's available.

Also, why are loops in general bad? I'm currently using a loop setup to spawn the heroes the players control via a dialogue button at the beginning of the map; Do I need to consider changing that, as well?
 

Ayanami

칼리
Reaction score
288
Loops aren't bad. If you add a wait in the loop, then it's bad. Real bad.

Okay, so here's the general idea for the trigger.

Trigger:
  • Combat Knife
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Com|cffffcc00b|rat Knife (Neutral Hostile)
    • Actions
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • Set CasterLoc = (Position of Caster)
      • Set TargetLoc = (Position of Target)
      • Set RealAngle = (Angle from CasterLoc to TargetLoc)
      • Custom script: call RemoveLocation(udg_CasterLoc)
      • Custom script: call RemoveLocation(udg_TargetLoc)
      • Trigger - Turn on Combat Knife Periodic <gen>
      • Wait 1.00 seconds
      • Trigger - Turn off Combat Knife Periodic <gen>


Trigger:
  • Combat Knife Periodic (Initially Off)
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Set TargetLoc = (Position of Target)
      • Set Offset = (TargetLoc offset by 12.00 towards RealAngle degrees)
      • Unit - Move Target instantly to Offset
      • Custom script: call RemoveLocation(udg_TargetLoc)
      • Custom script: call RemoveLocation(udg_Offset)


Variables:
Caster - Unit
Target - Unit
CasterLoc - Point
TargetLoc - Point
Offset - Point
RealAngle - Real

Okay, so here's whats happening. When you cast the spell, it basically gets the caster and unit locations. Then you get the angle you want, which is the angle which you're facing towards the target. Then, you turn on another trigger (Initially off) which moves the target by 12 distance every 0.04 seconds. After 1 second, the periodic trigger is turned off again. So the result would be that the target is knocked back by 300 distance (1.00/0.04 * 12) over 1 second. Note that if 2 units were to be knocked back simultaneously, the trigger would go haywire. Why? The variables would be overridden. If you want the trigger to fire simultaneously, it's a whole different trigger. You'll need to know MUI, which basically allows the spell to occur simultaneously without overriding each other. Hope this helped.

Note: If you're wondering what the "Custom Scripts" are for, they are to remove leaks. Certain variables such as Points and unit groups causes leaks. Thus you have to remove them before setting them into another variable. Leaks can lead to massive lag.
 

Tarivol

New Member
Reaction score
2
Not to be a bother, but I have no idea what MUI is, and unfortunately, since I'm creating a map in which up to ten players could all play the hero with this ability, I need to figure out how to make the spell not go hugely wrong when more than one person uses it. How advanced is what we're now talking about?\

Also, I've read a tiny bit about the leaking problem; How do I tell if a trigger will lag, or if something in a trigger will lag? I'm planning on this map being huge by the time I'm done, so, I don't want to end up with a 256x256 pile of lag when I'm done.

Side note; Would I be able to code ten versions of the same trigger, in order to make it so that each player would have their own set of variables, in case of everyone picking the same class? I know that's messy, but would that be a viable alternative to learning MUI, whatever that is?
 

Ayanami

칼리
Reaction score
288
MUI is basically using arrays to simultaneously allow the trigger to be run. There are only certain type of variables that leaks. There should be a tut on leaks in the forum. Try the search. As for the MUI knock back, here's a trigger.

Trigger:
  • Combat Knife
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Com|cffffcc00b|rat Knife (Neutral Hostile)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CustomValue Less than 100
        • Then - Actions
          • Set CustomValue = (CustomValue + 1)
        • Else - Actions
          • Set CustomValue = 1
      • Set Caster[CustomValue] = (Triggering unit)
      • Set Target[CustomValue] = (Target unit of ability being cast)
      • Set CasterLoc = (Position of (Triggering unit))
      • Set TargetLoc = (Position of (Target unit of ability being cast))
      • Set RealAngle[CustomValue] = (Angle from CasterLoc to TargetLoc)
      • Set RealTimer[CustomValue] = 1.00
      • Unit - Create 1 Hidden Dummy for (Owner of (Triggering unit)) at CasterLoc facing Default building facing degrees
      • Unit - Set the custom value of (Last created unit) to CustomValue
      • Unit Group - Add (Last created unit) to DummyGroup
      • Custom script: call RemoveLocation(udg_CasterLoc)
      • Custom script: call RemoveLocation(udg_TargetLoc)


Trigger:
  • Combat Knife Periodic
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
      • (DummyGroup is empty) Equal to False
    • Actions
      • Unit Group - Pick every unit in DummyGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RealTimer[TempInt] Less than or equal to 0.00
            • Then - Actions
              • Unit - Remove (Picked unit) from the game
            • Else - Actions
              • Set TargetLoc = (Position of Target[TempInt])
              • Set Offset = (TargetLoc offset by 12.00 towards RealAngle[TempInt] degrees)
              • Unit - Move Target[TempInt] instantly to Offset
              • Custom script: call RemoveLocation(udg_TargetLoc)
              • Custom script: call RemoveLocation(udg_Offset)
              • Set RealTimer[TempInt] = (RealTimer[TempInt] - 0.04)


Variables:
CustomValue - Integer
TempInt - Integer
CasterLoc - Point
TargetLoc - Point
Offset - Point
RealAngle - Real Array Size 100
RealTimer - Real Array Size 100
Caster - Unit Array Size 100
Target - Unit Array Size 100
Dummy Group - Unit Group

Note that all triggers are now Initially on. So that's an MUI version of it. It will work as much as 100 times per instance. There's also something called MPI which basically allows the same spell to fire at the same instance for different players. MUI allows the spell to be used at the same instance by anyone. If you have any questions on the trigger, feel free to ask.

Note: Hidden Dummy is a unit that has no model and doesn't show in the map. To create a hidden dummy, firstly, create a footman. Set attacks enabled to none and reduce food cost to 0. Go to the model path and set the path to ".mdl" without the quotations. Now go to normal abilities and add the ability "Locust", or simply press shit and double left-click on the normal abilities section and type in "Aloc" without the quotations. And there you have a hidden dummy.
 

Tarivol

New Member
Reaction score
2
Thank you incredibly much. So you know, I'm going to end up reviewing the triggers you posted bit by bit and attempting to decipher them, and I may end up PMing you if part or all of what I'm reading, I can't manage to decipher.
 

Ayanami

칼리
Reaction score
288
Thank you incredibly much. So you know, I'm going to end up reviewing the triggers you posted bit by bit and attempting to decipher them, and I may end up PMing you if part or all of what I'm reading, I can't manage to decipher.

Sure thing. Feel free to ask if you need help :thup:
 

Tarivol

New Member
Reaction score
2
Alright, so, since there isn't a way to directly copy what you posted to paste it into the trigger editor, I recreated them the best that I could, and came up with these;

Trigger:
  • Combat Knife
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Com|cffffcc00b|rat Knife Rifleman
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CustomValue Less than 100
        • Then - Actions
          • Set CustomValue = (CustomValue + 1)
        • Else - Actions
          • Set CustomValue = 1
      • Set Caster[CustomValue] = (Triggering unit)
      • Set Target[CustomValue] = (Target unit of ability being cast)
      • Set CasterLoc = (Position of (Triggering unit))
      • Set TargetLoc = (Position of (Target unit of ability being cast))
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at CasterLoc facing Default building facing degrees
      • Unit - Set the custom value of (Last created unit) to CustomValue
      • Unit Group - Add (Last created unit) to DummyGroup
      • Custom script: call RemoveLocation(udg_CasterLoc)
      • Custom script: call RemoveLocation(udg_TargetLoc)


Trigger:
  • Combat Knife Periodic
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
      • (DummyGroup is empty) Equal to False
    • Actions
      • Unit Group - Pick every unit in DummyGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RealTimer[TempInt] Less than or equal to 0.00
            • Then - Actions
              • Unit - Remove (Picked unit) from the game
            • Else - Actions
              • Set TargetLoc = (Position of Target[TempInt])
              • Set Offset = (TargetLoc offset by 12.00 towards RealAngle[TempInt] degrees)
              • Unit - Move Target[TempInt] instantly to Offset
              • Custom script: call RemoveLocation(udg_TargetLoc)
              • Custom script: call RemoveLocation(udg_Offset)
              • Set RealTimer[TempInt] = (RealTimer[TempInt] - 0.04)


I created the variables you listed, and I already had a dummy unit created, so I used that as the dummy unit in the dummy unitgroup.. Am I doing something wrong?

Most notably, there are some icon differences;

For your combat knife Ability Being Cast condition line, the icon is a cog; for mine, it's a question mark.

for your combat knife CustomValue less than 100, again, yours is a cog, mine is a question mark.

for your combat knife periodic, the initial timer is a cog; for mine, it's a stopwatch.

for your combat knife periodic, the dummygroup is empty line is a cog, for mine it's a question mark.

for your combat knife periodic, the realtimer[tempint] less than or equal to 100 line is a cog, for mine it's a question mark.

Are those icons important, and any idea why it still might not be working?

Sorry to keep bothering you after you posted a complete pair of triggers. x.X
 

Ayanami

칼리
Reaction score
288
Nope, the icon is just a forum thing. You missed out 2 lines on the first trigger.

Trigger:
  • Actions
    • Set RealAngle[CustomValue] = (Angle from CasterLoc to TargetLoc)
    • Set RealTimer[CustomValue] = 1.00


Because, by default the RealTimer variable is set as 0.00. So basically you left it at 0.00. And my second trigger condition halts the knock back action when RealTimer becomes 0.00. By setting it to 1.00 like shown above, you're actually setting the time taken to knock back to 1 second. And every 0.04 seconds, 0.04 is deducted from the 1.00. So it's like a timer to stop the knock back after 1 second.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top