MY maths fails, help plz

Weyird

Member
Reaction score
5
OK I have an ability that is supposed to affects all units in front of my caster in a wide arc (say about 150 degrees) within 340 range.

But my maths on how to select these units for the ability is failing me... Right now I've got:

Unit group - Pick every unit in (Units within 340 of (Position of (Casting Unit)) matching ((Abs(((Angle from (Position of (Casting Unit)) to (Position of (Matching Unit))) - (Facing of (Casting Unit))))) Less than or equal to 150)) and do (Actions)

It looks to me like it should work, but its not :(


PS: How do you post your triggers? Because i think the entire trigger might be flawed...
 

millz-

New Member
Reaction score
25
What I did for 1 of the custom spells I made was (a Breath of Fire that destroys trees in an arc infront), I do a left limit and right limit angle (facing of caster -75 or something = left limit, +75 = right limit). Then I get units within the wanted range, and check that the angle from caster to the unit is greater than the left limit, and less than the right limit.
 

malfy

New Member
Reaction score
4
PS: How do you post your triggers? Because i think the entire trigger might be flawed...

Right-click on the name of your trigger and select 'copy as text' then paste it on the forums between a pair of WC3 GUI tags...

asdfow.jpg
 

Weyird

Member
Reaction score
5
Trigger:
  • Staff Blow Area
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Staff Blow
    • Actions
      • Set Knockback = (80.00 + ((Real((Level of Staff Blow for (Triggering unit)))) x 20.00))
      • Unit Group - Pick every unit in (Units within 340.00 of (Position of (Triggering unit)) matching ((Abs(((Angle from (Position of (Triggering unit)) to (Position of (Matching unit))) - (Facing of (Triggering unit))))) Less than or equal to 150.00)) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to Knocked_Units
          • If ((Picked unit) Equal to (Casting unit)) then do (Unit Group - Remove (Picked unit) from Knocked_Units) else do (Do nothing)
      • For each (Integer A) from 1 to (Number of units in Knocked_Units), do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Random 1 units from Knocked_Units) and do (Actions)
            • Loop - Actions
              • Set Knocked_Unit[(Integer A)] = (Picked unit)
              • Unit Group - Remove (Picked unit) from Knocked_Units
              • Unit - Set Knocked_Unit[(Integer A)] movement speed to 0.00
      • For each (Integer B) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set Move_To[(Integer A)] = ((Position of Knocked_Unit[(Integer A)]) offset by Knockback towards (Angle from (Position of (Triggering unit)) to (Position of Knocked_Unit[(Integer A)])) degrees)
          • Destructible - Pick every destructible within 130.00 of Move_To[(Integer A)] and do (Destructible - Kill (Picked destructible))
          • Unit - Move Knocked_Unit[(Integer A)] instantly to Move_To[(Integer A)]
          • Special Effect - Create a special effect at (Position of Knocked_Unit[1]) using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
          • Set Knockback = (Knockback x 0.70)
          • Wait 0.01 seconds
      • Unit - Set Knocked_Unit[(Integer A)] movement speed to (Default movement speed of Knocked_Unit[(Integer A)])
      • For each (Integer C) from 1 to (Integer A), do (Set Knocked_Unit[(Integer A)] = No unit)
      • Unit Group - Pick every unit in Knocked_Units and do (Unit Group - Remove (Picked unit) from Knocked_Units)





OK so whats wrong with that? I suspect it's the line that targets the units. I'll try the BoF idea
 

Laiev

Hey Listen!!
Reaction score
188
Trigger:
  • Staff Blow Area
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Staff Blow
    • Actions
      • Set Knockback = (80.00 + ((Real((Level of Staff Blow for (Triggering unit)))) x 20.00))
Trigger:
  • Unit Group - Pick every unit in (Units within 340.00 of (Position of (Triggering unit)) matching ((Abs(((Angle from (Position of (Triggering unit)) to (Position of (Matching unit))) - (Facing of (Triggering unit))))) Less than or equal to 150.00)) and do (Actions)
    • Loop - Actions

you leak here... pick every unit in <units withim...> set the group in variable and use the variable
Trigger:
  • Unit Group - Add (Picked unit) to Knocked_Units
    • If ((Picked unit) Equal to (Casting unit)) then do (Unit Group - Remove (Picked unit) from Knocked_Units) else do (Do nothing)
    • For each (Integer A) from 1 to (Number of units in Knocked_Units), do (Actions)
      • Loop - Actions
        • Unit Group - Pick every unit in (Random 1 units from Knocked_Units) and do (Actions)
          • Loop - Actions
            • Set Knocked_Unit[(Integer A)] = (Picked unit)
            • Unit Group - Remove (Picked unit) from Knocked_Units
            • Unit - Set Knocked_Unit[(Integer A)] movement speed to 0.00
    • For each (Integer B) from 1 to 8, do (Actions)
      • Loop - Actions
        • Set Move_To[(Integer A)] = ((Position of Knocked_Unit[(Integer A)]) offset by Knockback towards (Angle from (Position of (Triggering unit)) to (Position of Knocked_Unit[(Integer A)])) degrees)
        • Destructible - Pick every destructible within 130.00 of Move_To[(Integer A)] and do (Destructible - Kill (Picked destructible))
        • Unit - Move Knocked_Unit[(Integer A)] instantly to Move_To[(Integer A)]
        • Special Effect - Create a special effect at (Position of Knocked_Unit[1]) using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
        • Set Knockback = (Knockback x 0.70)
        • Wait 0.01 seconds
    • Unit - Set Knocked_Unit[(Integer A)] movement speed to (Default movement speed of Knocked_Unit[(Integer A)])
    • For each (Integer C) from 1 to (Integer A), do (Set Knocked_Unit[(Integer A)] = No unit)
    • Unit Group - Pick every unit in Knocked_Units and do (Unit Group - Remove (Picked unit) from Knocked_Units)


not 100% sure but i think you can't use waits inside loops

what happen when you cast it?

what is the last move of the trigger.. the effect happen? the unit is knockback? what happen?
 

Weyird

Member
Reaction score
5
you leak here... pick every unit in <units withim...> set the group in variable and use the variable

Firstly, whats a leak? Secondly, I do put it into a variable - Knocked Units? Unless I missunderstand?

As for the effect, sometimes it works right, but mostly not. It seems to work behind the hero mostly, but sometimes in front. Where I am relative to the enemy seems to make a difference (north, south, east, west, etc) which leads me to believe its the math targeting them. But generally when the effect happens, it happens right. Though I do have the hiccup of sometimes, but not always, their move speed isn't restored..

As for the wait function in a loop, generally I've learned it doesn't work either, and i admit it doesn't seem to work right, but it does create pause enough between the instant unit moves.

Trigger:
  • Staff Blow
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Staff Blow
    • Actions
      • Set Knockback = (80.00 + ((Real((Level of Staff Blow for (Triggering unit)))) x 20.00))
      • Set Knocked_Unit[1] = (Target unit of ability being cast)
      • Unit - Set Knocked_Unit[1] movement speed to 0.00
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set Move_To[1] = ((Position of Knocked_Unit[1]) offset by Knockback towards (Angle from (Position of (Triggering unit)) to (Position of (Target unit of ability being cast))) degrees)
          • Unit - Move Knocked_Unit[1] instantly to Move_To[1]
          • Special Effect - Create a special effect at (Position of Knocked_Unit[1]) using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
          • Set Knockback = (Knockback x 0.70)
          • Wait 0.01 seconds
      • Unit - Set Knocked_Unit[1] movement speed to (Default movement speed of Knocked_Unit[1])


That's my original ability that only targets one unit and it works fine...
 

werasd

New Member
Reaction score
14
>> Firstly, whats a leak? Secondly, I do put it into a variable - Knocked Units? Unless I missunderstand.

A leak is when something in your map uses an unnecessary memory. That is accumulative, so you can get a lot of lag from that. To remove memory leaks, you have to destroy what you've done. What Laiev said, is that you should make a Unit Group variable instead of getting the units in the range and then destroy it (use "Custom Script: call DestroyGroup(udg_yourvariable)).
 

Ayanami

칼리
Reaction score
288
I suggest using a separate periodic trigger for your knock back. Use a 0.04 seconds periodic trigger to constantly move the units.
 

Lifespiker

New Member
Reaction score
1
Some things for ya Weyird.

1. This forum LOVES to hate leaks - Leaks are something extra to be dealt with once you know what you're doing a little more. Ignore leaks for now. The first map I made leaked like a bucket with a hole in it and I could play the thing for 2 hours straight without any noticeable problems.

2. There's no need to mess with the unit's movement speed - When using a Move To many times in a row, the unit can't move anyway.

3. The "Wait" trigger's minimum value is 0.2 - Anything lower than this will just become 0.2 anyway!

4. The best way to move units like this is with a Periodic trigger - Under Actions you can do Periodic Event. This can be set as FAST as you want. The 0.2 limit does not apply here like it does to the Wait. This would be a trigger that would initially be Off, but turned On and Off as needed.

5. No using Wait in loops!

Lifespiker :)
 

Weyird

Member
Reaction score
5
OK great, the periodic thing would work really well IF someone could tell me how to reference Intiger A in the second trigger..


Also, something completely different but not lus 2 make a new thread for it:
How can I reference which unit is the target of an item? Or does "uses an ability" work and then making the condition that the ability is the one in the item?
 

HydraRancher

Truth begins in lies
Reaction score
197
1. This forum LOVES to hate leaks - Leaks are something extra to be dealt with once you know what you're doing a little more. Ignore leaks for now. The first map I made leaked like a bucket with a hole in it and I could play the thing for 2 hours straight without any noticeable problems.

Erm what? Its not the forum, its simpley WC3 players! Do you want a game where it takes 10 seconds to buy a hero? I think not!




2. There's no need to mess with the unit's movement speed - When using a Move To many times in a row, the unit can't move anyway.

Not quite, he DOES need to disable the unit, so hes actually better off pausing.



3. The "Wait" trigger's minimum value is 0.2 - Anything lower than this will just become 0.2 anyway!


0.27.....




4. The best way to move units like this is with a Periodic trigger - Under Actions you can do Periodic Event. This can be set as FAST as you want. The 0.2 limit does not apply here like it does to the Wait. This would be a trigger that would initially be Off, but turned On and Off as needed.

The first part is right. The second part is SUI (Single Unit Instable (Which is VERY bad!)).
Dont use turn on/off, better off adding to a unit group, or adding a buff.




5. No using Wait in loops!


Now who told you that? LIES!!! If it is MUI then waits in an integer loop is OK! I use it to spawn 10 zombies in my game, works perfectly.









Also, something completely different but not lus 2 make a new thread for it:
How can I reference which unit is the target of an item? Or does "uses an ability" work and then making the condition that the ability is the one in the item?

Make a new thread.
 

werasd

New Member
Reaction score
14
Some things for ya Weyird.

1. This forum LOVES to hate leaks - Leaks are something extra to be dealt with once you know what you're doing a little more. Ignore leaks for now. The first map I made leaked like a bucket with a hole in it and I could play the thing for 2 hours straight without any noticeable problems.

2. There's no need to mess with the unit's movement speed - When using a Move To many times in a row, the unit can't move anyway.

3. The "Wait" trigger's minimum value is 0.2 - Anything lower than this will just become 0.2 anyway!

4. The best way to move units like this is with a Periodic trigger - Under Actions you can do Periodic Event. This can be set as FAST as you want. The 0.2 limit does not apply here like it does to the Wait. This would be a trigger that would initially be Off, but turned On and Off as needed.

5. No using Wait in loops!

Lifespiker :)


1 - No comments.



>> How can I reference which unit is the target of an item? Or does "uses an ability" work and then making the condition that the ability is the one in the item?

Yes it works, if you set the condition to ITEM ability.


And Lifespiker, before giving someone a life guidance (actually a WE guidance), think twice.
 

Lifespiker

New Member
Reaction score
1
Man, I knew I'd get torn up for trying to help, but I didn't think it would be so soon! Thanks everyone!

By the way, all but number 1 were things I learned and have been applying based on this forum. And number 1 is just personal experience. Wouldn't want to add that into the mix!

Lifespiker
 

werasd

New Member
Reaction score
14
Personal experiences sometimes shouldn't be passed to another person everytime. Memory leaks should be avoided from the beginning, so you don't get used to forgetting them.

The other topics, i just don't mind.
 

Ayanami

칼리
Reaction score
288
1. This forum LOVES to hate leaks - Leaks are something extra to be dealt with once you know what you're doing a little more. Ignore leaks for now. The first map I made leaked like a bucket with a hole in it and I could play the thing for 2 hours straight without any noticeable problems.

Erm what? Its not the forum, its simpley WC3 players! Do you want a game where it takes 10 seconds to buy a hero? I think not!




2. There's no need to mess with the unit's movement speed - When using a Move To many times in a row, the unit can't move anyway.

Not quite, he DOES need to disable the unit, so hes actually better off pausing.



3. The "Wait" trigger's minimum value is 0.2 - Anything lower than this will just become 0.2 anyway!


0.27.....




4. The best way to move units like this is with a Periodic trigger - Under Actions you can do Periodic Event. This can be set as FAST as you want. The 0.2 limit does not apply here like it does to the Wait. This would be a trigger that would initially be Off, but turned On and Off as needed.

The first part is right. The second part is SUI (Single Unit Instable (Which is VERY bad!)).
Dont use turn on/off, better off adding to a unit group, or adding a buff.




5. No using Wait in loops!


Now who told you that? LIES!!! If it is MUI then waits in an integer loop is OK! I use it to spawn 10 zombies in my game, works perfectly.











Make a new thread.

Waits ARE bad in loops. It causes all other loop functions to malfunction. However, it's okay if you use a separate integer rather than Integer A and Integer B.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top