Creating Unit via loops Problem

0WN3D

New Member
Reaction score
15
I tried to have a skill that creates 6 units around a unit that is 60 degrees apart.( Furion Sprout From DotA but not trees but units) Heres my trigger

Trigger:
  • TreeOfLife
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to TreeOfLife
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of TreeOfLife for (Casting unit)) Equal to 1
        • Then - Actions
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at ((Position of (Target unit of ability being cast)) offset by 600.00 towards ((Real((Integer A))) x 60.00) degrees) facing Default building facing degrees
              • Unit - Add Drain Life to (Last created unit)
              • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
              • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
        • Else - Actions




The problem is that onli 1 unit is created instead of 6. + rep for any help... ( The spell targets Unit)
 

0WN3D

New Member
Reaction score
15
I know ... I know ... leaks... I don't really bother about them because it really takes a while to remove them as you need to type ( RemoveLocation) or something like that... well additional information should be that onli 1 unit is created and it is in 60 degrees of the unit and the distance(more or less) is correct and the spell base is storm bolt...
 

X-maul

AKA: Demtrod
Reaction score
201
uhmm - well you should realy consider removing leaks - you jsut need to type
Code:
RemoveLocation(udg_[COLOR="Red"]VariableName[/COLOR])
othervise your game will start to lag.
 

0WN3D

New Member
Reaction score
15
Triggering Unit did not work... sighz more time to check my trigger and object editors...

Edit: NEW INFO!!! Weirdly, i also cannot trigger it the long way. It also creates onli 1 unit.
Trigger:
  • Then - Actions
    • Unit - Create 1 TreeOfLife for (Owner of (Triggering unit)) at ((Position of (Target unit of ability being cast)) offset by 600.00 towards (2.00 x 60.00) degrees) facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
    • Unit - Create 1 TreeOfLife for (Owner of (Triggering unit)) at ((Position of (Target unit of ability being cast)) offset by 600.00 towards (3.00 x 60.00) degrees) facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
    • Unit - Create 1 TreeOfLife for (Owner of (Triggering unit)) at ((Position of (Target unit of ability being cast)) offset by 600.00 towards (4.00 x 60.00) degrees) facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
    • Unit - Create 1 TreeOfLife for (Owner of (Triggering unit)) at ((Position of (Target unit of ability being cast)) offset by 600.00 towards (5.00 x 60.00) degrees) facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
 

Ashlebede

New Member
Reaction score
43
uhmm - well you should realy consider removing leaks - you jsut need to type
Code:
RemoveLocation(udg_[COLOR="Red"]VariableName[/COLOR])
othervise your game will start to lag.

Ubar syntax error there. Correct code :

JASS:
call RemoveLocation(udg_VariableName)


And yes, it is considerably short to write and easy to remember. It really is no big deal, it's just a habit you should develop, since it reduces lag considerably in the long run (especially if you have triggers that run often).
 

vypur85

Hibernate
Reaction score
803
This is really weird. Try opening a new map and copy the trigger and run it to see if it works. Trigger usually stops half way if there's faulty or weird calls that don't make sense. Yours seem really fine to me.

Perhaps there's another trigger interfering? Unit removal trigger etc?
 

Inflicted

Currently inactive
Reaction score
63
the 'call' part is fairly obvious. I would suggest putting a line to test if the trigger is actually running. Perhaps the condition isn't being matched?

Try remove the condition and retry maybe.

And yeah you have alot of leaks, fix it and show us the new code please.
 

0WN3D

New Member
Reaction score
15
I may seem unexperience to leaks but actually im just lazy... heres the sorta fixed trigger

Loops:
Trigger:
  • TreeOfLife
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to TreeOfLife
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of TreeOfLife for (Triggering unit)) Equal to 1
        • Then - Actions
          • Set Temp_point = (Position of (Target unit of ability being cast))
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Set Temp_point2 = (Temp_point offset by 600.00 towards ((Real((Integer A))) x 60.00) degrees)
              • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
              • Unit - Add Drain Life to (Last created unit)
              • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
              • Custom script: call RemoveLocation(udg_Temp_point2)
          • Custom script: call RemoveLocation(udg_Temp_point)


'Old Fashioned':
Trigger:
  • Actions
    • Set Temp_point = (Position of (Target unit of ability being cast))
    • Set Temp_point2 = (Temp_point offset by 600.00 towards (1.00 x 60.00) degrees)
    • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Custom script: call RemoveLocation(udg_Temp_point2)
    • Set Temp_point2 = (Temp_point offset by 600.00 towards (2.00 x 60.00) degrees)
    • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Custom script: call RemoveLocation(udg_Temp_point2)
    • Set Temp_point2 = (Temp_point offset by 600.00 towards (3.00 x 60.00) degrees)
    • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Custom script: call RemoveLocation(udg_Temp_point2)
    • Set Temp_point2 = (Temp_point offset by 600.00 towards (4.00 x 60.00) degrees)
    • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Custom script: call RemoveLocation(udg_Temp_point2)
    • Set Temp_point2 = (Temp_point offset by 600.00 towards (5.00 x 60.00) degrees)
    • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Custom script: call RemoveLocation(udg_Temp_point2)
    • Set Temp_point2 = (Temp_point offset by 600.00 towards (6.00 x 60.00) degrees)
    • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
    • Unit - Add Drain Life to (Last created unit)
    • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Target unit of ability being cast)
    • Custom script: call RemoveLocation(udg_Temp_point2)
    • Custom script: call RemoveLocation(udg_Temp_point)



I will be posting and testing the test map tomorrow and hope any of you all can solve it...
 

vypur85

Hibernate
Reaction score
803
What's with you guys and leaks? It's not even the problem. =.= Almost half the posts are talking about bloody leaks, and they don't even solve or attempt to solve the damn problem. By the way, there're too many Temp_point, they're redundant. You only need to set once in the beginning and remove again at the end. (Due to copy and paste, perhaps?)

Replace the Life Drain with another ability and see if it works (Storm bolt, maybe). Add game text at each interval to see when does the action stops proceeding. Also, attempt to remove the ability addition and ability order, and just create 6 units. See if there are in fact 6 units created. I'm suspecting something is wrong with the Life Drain.

Couldn't be the condition problem, otherwise the 1 unit wouldn't have been created.

Then again, since you're posting the map, I guess we'll just wait. Or am I missing anything here?
 

0WN3D

New Member
Reaction score
15
Heres teh map... There is 2 triggers in it, 1 using loops and the other the old fashion...View attachment Tree Of Life Test Map.w3x

vypur85: I feel slightly that you are right about Life Drain as in the past this trigger ran without problems when the trees do not have enough mana to cast the spell... And you are totally right about copy and paste :p
 

vypur85

Hibernate
Reaction score
803
Code:
Trre Of Life Loops
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to TreeOfLife 
    Actions
        [B]Set unit = (Target unit of ability being cast)[/B]
        Set Temp_point = (Position of (Target unit of ability being cast))
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Set Temp_point2 = (Temp_point offset by 600.00 towards ((Real((Integer A))) x 60.00) degrees)
                Unit - Create 1 TreeOfLife for (Owner of (Triggering unit)) at Temp_point2 facing Default building facing degrees
                Unit - Add Drain Life  to (Last created unit)
                Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain [B]unit[/B]
                Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
                Custom script:   call RemoveLocation(udg_Temp_point2)
        Custom script:   call RemoveLocation(udg_Temp_point)

Add the variable and use it. Apparently the order caused 'Target unit ability being cast' to be somewhat... missing.
 

0WN3D

New Member
Reaction score
15
YAY!! This trigger cr8s all 6 units.... But however.. somehow the trees will no life drain the unit.. they jus stands there.. They are also in range for the spell as i can select and order them to cast spellz.

Edit: Nvm this... my fault.. i set TempUnit = Tempunit
 

0WN3D

New Member
Reaction score
15
nvm my previous post.... in that post i had TempUnit = Tempunit.... soo the life drain didnt work and there is 6 units.... Now i set it to TempUnit = Target Ability being cast and Im bak to square 1.... there is onli 1 unit again:banghead:. Soo i remove the Life drain casting part and it workz perfectly cr8ing 6 units... So i guess something is wrong with lfie drain that it can stop loops..

Soo i decided to post my 'new' trigger that is filled with variables...

Trigger:
  • Trre Of Life Loops
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to TreeOfLife
    • Actions
      • Set Temp_Unit = (Target unit of ability being cast)
      • Set Temp_point = (Position of Temp_Unit)
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Temp_point2 = (Temp_point offset by 300.00 towards ((Real((Integer A))) x 60.00) degrees)
          • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
          • Set Temp_Unit2 = (Last created unit)
          • Unit - Add Drain Life to Temp_Unit2
          • Unit - Order Temp_Unit2 to Neutral Dark Ranger - Life Drain Temp_Unit
          • Unit - Add a 5.00 second Generic expiration timer to Temp_Unit2
          • Custom script: call RemoveLocation(udg_Temp_point2)
      • Custom script: call RemoveLocation(udg_Temp_point)
 

cleeezzz

The Undead Ranger.
Reaction score
268
put a debug message after every single line in the loop, see where it stops. also you could put a debug at the last line of the loop to show the value of integer A just in case something is messing with it.

for example, its possible that an action in your loop is firing off an event in another trigger that uses integer A and could potentially mess it up. Try changing it to , For integer variable loop, and use an integer you never use anywhere else.
 

0WN3D

New Member
Reaction score
15
I am pretty sure it is the Order Unit to Lifedrain Target part that is messing up as when i remove it, the trigger can create all 6 units... Currently checking my Integer A

Edit: Nvm.... I found out how to make it work....Heres the trigger in case you all are wondering
Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Level of TreeOfLife for (Triggering unit)) Equal to 1
    • Then - Actions
      • Set Temp_Unit = (Target unit of ability being cast)
      • Set Temp_point = (Position of Temp_Unit)
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Temp_point2 = (Temp_point offset by 600.00 towards ((Real((Integer A))) x 60.00) degrees)
          • Unit - Create 1 TreeOfLife for (Owner of (Casting unit)) at Temp_point2 facing Default building facing degrees
          • Unit - Add Drain Life to (Last created unit)
          • Unit Group - Add (Last created unit) to Temp_Group
          • Custom script: call RemoveLocation(udg_Temp_point2)
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Neutral Dark Ranger - Life Drain Temp_Unit
          • Unit Group - Remove (Pick unit) From Temp_Group
      • Custom script: call DestroyGroup(udg_Temp_Group)
      • Custom script: call RemoveLocation(udg_Temp_point)
    • Else - Actions


I think that Lifedrain Stops loops.... Wierd...o_O

:Edit!! Case Reopens.... This trigger onli allows me to cast onli one time then i workz perfectly.. but when i cast it a secnod time, it doesnt drain the life of the unit.. even more weird...
 
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