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

Help on Multishot (Spread shot) projectiles

Status
Not open for further replies.
Level 1
Joined
Dec 8, 2019
Messages
2
So i was inspired by Dota 2's Snapfire Scatterblast...And i was planning to add a similar ability to my maps of custom heroes and i did succeed...however, whenever the caster casts the ability on the very x axis, the projectiles seem to be cramped together instead of spreading....I already tried setting coordinates for x and y...however whenever the caster casts on the z axis, it would cramp up just like that with the x axis



Expected outcome of the ability: (projectiles spread as expected)
works as normal.png




Ability doesn't spread as much when targeted on the z-axis
doesn't spread as much.png




Ability Doesn't spread at all when casted on the x axis:
really tight spread.png




here is what i encoded:
code.png




I tried giving the order string y-axis coordinates but the spell would not spread when casting at the z-axis:
z-axis.png




This is what i did when i tried to "fix it"....
code2.png




Sooooo.....What do i do to fix this?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,561
  • Spread Shot Cast Uncle
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spread Shot (Uncle)
    • Actions
      • -------- Variables --------
      • Set SS_Caster = (Triggering unit)
      • Set SS_Level = (Level of (Ability being cast) for SS_Caster)
      • -------- --- --------
      • Set SS_Points[1] = (Position of SS_Caster)
      • Set SS_Points[2] = (Target point of ability being cast)
      • -------- --- --------
      • Set SS_Angles[1] = (Angle from SS_Points[1] to SS_Points[2])
      • Set SS_Angles[2] = (SS_Angles[1] - 90.00)
      • Set SS_Angles[3] = (SS_Angles[1] - 45.00)
      • Set SS_Angles[4] = (SS_Angles[1] + 45.00)
      • Set SS_Angles[5] = (SS_Angles[1] + 90.00)
      • -------- --- --------
      • -------- Special Effect --------
      • Special Effect - Create a special effect attached to the hand of SS_Caster using Abilities\Weapons\LordofFlameMissile\LordofFlameMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- --- --------
      • -------- Dummy --------
      • Unit - Create 1 Dummy (Uncle) for (Triggering player) at SS_Points[1] facing Default building facing degrees
      • Set SS_Dummy = (Last created unit)
      • Unit - Add Spread Shot Dummy (Uncle) to SS_Dummy
      • Unit - Set level of Spread Shot Dummy (Uncle) for SS_Dummy to SS_Level
      • Unit - Add a 0.50 second Generic expiration timer to SS_Dummy
      • -------- --- --------
      • -------- Cast Dummy Abilities --------
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set SS_Points[3] = (SS_Points[1] offset by 100.00 towards SS_Angles[(Integer A)] degrees)
          • Unit - Order SS_Dummy to Neutral Pandaren Brewmaster - Breath Of Fire SS_Points[3]
          • Custom script: call RemoveLocation (udg_SS_Points[3])
      • -------- --- --------
      • -------- Clean Up Leaks --------
      • Custom script: call RemoveLocation (udg_SS_Points[1])
      • Custom script: call RemoveLocation (udg_SS_Points[2])
      • Wait 0.10 seconds
      • -------- Play Sound --------
      • Sound - Play CatapultAttack1 <gen> at 100.00% volume, attached to (Triggering unit)

Some problems with your trigger:

1) You generally want to use "A unit starts the effect of an ability" instead of "A unit begins casting an ability". Begins casting an ability will run the trigger even if the ability didn't actually "go off". For example, if you issue a "Stop" order on your Hero immediately after casting an ability the ability will be cancelled, however, the Event "begins casting an ability" will still go off and the trigger will execute.
"Starts the effect of an ability" fires when the ability goes on cooldown so it doesn't have this issue.

2) You're leaking Points with your use of "Position of triggering unit". Position of unit, center of region, etc... these all create Points that will leak if you don't set them as Variables yourself and Remove them yourself.

3) You're using an unnecessary amount of Dummy units. You only need 1 Dummy in most cases like these. You can also use an Expiration Timer to destroy your Dummy. Also, set your Dummy's Movement Type to None and Speed Base to 0 in the Object Editor and make sure it's Art - Cast Point and Art - Cast Backswing are set to 0.00. (Or copy the Dummy unit from my map and use that one)

4) You don't need the "TempEffect1" variable, you can use "Destroy last created Special Effect" instead.

5) The Variables "TempUnit1-5" and "TempPos2" are referenced AFTER the use of Waits. This can cause problems if you use those Variables in other Triggers or if you cast this ability additional times in quick succession.

^However, if the ability has a long enough cooldown (longer than the sum of your Waits) and these variables are used ONLY for this Trigger then it's not a problem. But if you do use these Variables in other triggers then you might end up replacing what those Variables are "pointing" to and that will cause some problems.

Here's an example of what I'm talking about:
  • Ex 1
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Unit - Create 5 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
  • Ex 2
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • Wait 2.00 seconds
      • Unit - Kill TempUnit
See the problem? Only 1 of those 5 Footman will die even though they have all "Entered the map". That's because i'm setting TempUnit to the most recent unit that has entered the map. Meaning only the very last of those 5 Footman will be considered TempUnit. The other 4 will no longer be TempUnit therefore they won't die. So in your Trigger's case you might accidentally change TempUnit or TempPos2 to something else during that 0.50 second Wait.

How To Post Your Trigger
Things That Leak
 

Attachments

  • Spread Shot Uncle.w3x
    19.9 KB · Views: 23
Last edited:
Disregard the Wait usage and leaks, this part
code2-png.342214


is usually not correct. To produce consistent results no matter which angle the caster is facing, you have to use trigonometric functions to move dummy units. For example:
set TempPos = position of the dummy
set NextPos = TempPos offset by (50*Sin(Facing of dummy),50*Cos(Facing of dummy))
This ensures that the NextPos is always 50 distance from TempPos, in the direction that the dummy is facing.
 
Status
Not open for further replies.
Top