Custom Spell - Driving me nuts.

Baltazhar

Active Member
Reaction score
55
I made and remade this ability 3 times, because they wouldn't work.
The idea of the ability is: Use entangle, and another 5/10/15 nearby enemy creeps get hit as well.

I started by doing it from my own head, then checking for ideas from the 'Overgrowth' DotA spell, and then finally and tried making the same spell, but in a different manner.

Hope someone can see what I'm missing here.

Variables:
ChokingVinesPreviousTarget = Unit
ChokingVinesTarget = Unit

Both variables are only used in the posted trigger.

Code:
Choking Vines
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Choking Vines 
    Actions
        Set ChokingVinesPreviousTarget = (Target unit of ability being cast)
        For each (Integer A) from 1 to (((Level of Choking Vines  for (Casting unit)) x 5) - 1), do (Actions)
            Loop - Actions
                Set Temp_Point = (Position of ChokingVinesPreviousTarget)
                Set Temp_Group = (Units within 300.00 of Temp_Point matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True))
                Custom script:   call RemoveLocation (udg_Temp_Point)
                Unit Group - Pick every unit in Temp_Group and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Or - Any (Conditions) are true
                                    Conditions
                                        ((Picked unit) is dead) Equal to True
                                        ((Picked unit) has buff Choking Vines) Equal to True
                            Then - Actions
                                Unit Group - Remove (Picked unit) from Temp_Group
                            Else - Actions
                Game - Display to (All players) the text: (String((Number of units in Temp_Group)))
                Set ChokingVinesTarget = (Random unit from Temp_Group)
                Custom script:   call DestroyGroup (udg_Temp_Group)
                Unit - Create 1 Choking Vines (unit) for (Owner of (Casting unit)) at Temp_Point facing Default building facing degrees
                Unit - Add Choking Vines (dummy) to (Last created unit)
                Unit - Set level of Choking Vines (dummy) for (Last created unit) to (Level of Choking Vines  for (Casting unit))
                Unit - Order (Last created unit) to Night Elf Keeper Of The Grove - Entangling Roots ChokingVinesTarget
                Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                Set ChokingVinesPreviousTarget = ChokingVinesTarget

The idea was the following steps.
1: Hero casts basic entangle
2: Sets unitgroup within 300 of targeted unit
3: Remove dead and alrdy entangled units from group
4: Selects random from the remaining group
5: Create dummy unit, give it dummy ability, set dummy level of ability
6: Order dummy unit to entangle selected target from unit group
7: Repeat (Ability Level x 5 -1) times

What basically happens is, regular entangle, no additional ones.
I've checked that the number of repeats is correct, but the remaining number units in the group after the sorting out, seems a bit wrong somehow. Made a test where I had 3 enemy units, cast entangle on one of them (that one should be filtered out), and the still said there was 3 targets in the unit group.

Perhaps I'm blabbering too much in here, and should simply just have pasted the code and wrote "HELP!". Anyway, I'd be thankful for any clues that could lead to the solving of my problem. Rewarding reputation ofcourse.

Thanks in advance,
Baltazhar
 

Squishy

You can change this now in User CP.
Reaction score
127
Are you sure the dummies have enough mana to cast the ability?
 

Atreyu

One Last Breath.
Reaction score
49
Don't quite get the Question. You mean overgrowth right? What about doing a special effect instead?
Code:
Event
 A unit casts an ability
Conditions
 Ability being cast equal to [COLOR="Red"]( Your Ability )[/COLOR]
Action
 Set Temp_Unit = Target unit of ability being cast
 Set Temp_Group = Units within 250.00 of Temp_Unit matching (mathicng unit) is an enemy of casting unit.
  Unit Group = Pick every unit in Temp_Group and do actions
      Loop = Pause Picked unit
                Create a special effect in position of picked unit with entangle.mdl
                Create 1 dummy unit in position of picked player
          -------------- That damages them ----------------
 

Beast

New Member
Reaction score
5
Rather than random unit in temp_group it makes more sense to just say 'picked unit'. Also I think the 'if' isn't even really needed at all, just say pick every unit and make dummy and cast entangle on picked unit(if theres a dead unit an extra dummy is spawned and if something as entangle already it gets entangled again but not really a big deal).
 

Squishy

You can change this now in User CP.
Reaction score
127
You need to remove dead and already entangled units in order for the right number of units to be entangled.
 

Beast

New Member
Reaction score
5
Ah I get it now disregard what I said. The only other problem I could see is you have it check to see whether a unit has a the buff already but since its all happening instantly(basically) I'm thinking it won't have enough time to notice the roots that have already happend(and especially the first one since its unit 'starts' an ability) since it takes a little time to 'cast' roots and give a unit the debuff and thus won't filter them out of the group. Not positive if thats the problem but I stared at it for about 10 minutes and that was the only problem I could come up with.
 

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
Baltazhar:

Unit - Create 1 Choking Vines (unit) for (Owner of (Casting unit)) at Temp_Point facing Default building facing degrees

Reasons your code didn't work, you didn't set the location for the dummy to appear, so by default they would be at (0,0) which is too far away for their entangle to work. The previous "Temp_Point" was removed.


Also, You might want to re-organise your coding steps, in theory, it will be like the following.

1: Hero casts basic entangle
2: Sets unitgroup within 300 of targeted unit
3: Remove dead and targeted unit from group

LOOP - Repeat (Ability Level x 5 -1) times
4: Set "A" = a unit randomly selected from the remaining group
5: Create dummy unit, give it dummy ability, set dummy level of ability,
6: Give dummy unit an expiration timer of 1 sec
7: Order dummy unit to entangle "A"
8: Remove "A" from unitgroup
9: Do a "If" check to make sure unitgroup is NOT empty,
LOOP END

Basically, it Makes a unit group of your desired targets, then randomly pick X amount of units out of it.

Notes:
- New Variable "A" << please rename it
- Give dummy units 1,000 maximum mana and 1,000 starting mana
- Remember to remove leaks
- This is just for improving code efficiency
 

Baltazhar

Active Member
Reaction score
55
Choking Vines (unit) is ofcourse a dummy unit I made with the 'bugger' skin to make it invisible.

Choking Vines (dummy) is the dummy spell, which is the same as the original spell except: 0 mana cost, 99999 range, 0 cooldown and it's a Unit Ability (not hero).

I started by wanting a template-overgrowth spell, but then I changed the idea a bit. That's why my code is a bit different from the actual 'overgrowth'.
The spell should look like the first target is entangled, then another within 300 of that, and then another within 300 of the previous target etc. So the entangles makes a path (i was hoping) in the enemy units. Thereby meaning, a random path through mobs, just as a Chain Lightning would do it. Not entangling X units within a range of first target.
This can be altered if I find that the above can't be done, or if I find it too complicated (I'm a bit lazy sometimes) :)

It was true about the Temp_Point being removed before it was for the unit creation. I moved the RemoveLocation to the bottom of the trigger, so it is removed after the last usage of it.

Beast: I thought about ur suggestion, but I am pretty sure that, eventhough everything happens 'instantly' according to the player ingame, the Editor knows how to do things that fast. But seeing as nothing else has worked, I thought 'Why not give it a try'.
And guess what, it kinda did the trick. It now not only entangles the first target, but also 1 other target. So I think we're on the right track here :)

If this still doesn't turn out to be duable, I'm trying it the 'Overgrowth'-way. Entangling X creeps around the target.

My trigger now looks like this
Code:
Choking Vines
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Choking Vines 
    Actions
        Set ChokingVinesPreviousTarget = (Target unit of ability being cast)
        For each (Integer A) from 1 to (((Level of Choking Vines  for (Casting unit)) x 5) - 1), do (Actions)
            Loop - Actions
                Wait 0.10 seconds
                Set Temp_Point = (Position of ChokingVinesPreviousTarget)
                Set Temp_Group = (Units within 300.00 of Temp_Point matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True))
                Unit Group - Pick every unit in Temp_Group and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Or - Any (Conditions) are true
                                    Conditions
                                        ((Picked unit) is dead) Equal to True
                                        ((Picked unit) has buff Choking Vines) Equal to True
                            Then - Actions
                                Unit Group - Remove (Picked unit) from Temp_Group
                            Else - Actions
                Game - Display to (All players) the text: (String((Number of units in Temp_Group)))
                Set ChokingVinesTarget = (Random unit from Temp_Group)
                Custom script:   call DestroyGroup (udg_Temp_Group)
                Unit - Create 1 Choking Vines (unit) for (Owner of (Casting unit)) at Temp_Point facing Default building facing degrees
                Unit - Add Choking Vines (dummy) to (Last created unit)
                Unit - Set level of Choking Vines (dummy) for (Last created unit) to (Level of Choking Vines  for (Casting unit))
                Unit - Order (Last created unit) to Night Elf Keeper Of The Grove - Entangling Roots ChokingVinesTarget
                Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                Set ChokingVinesPreviousTarget = ChokingVinesTarget
                Custom script:   call RemoveLocation (udg_Temp_Point)

Forgot to mention, that the Game - Display message is just to check how many targets are left in the group after removing dead/buffed units (in both triggers pasted). To check if the counted correctly, as a part of my 'look for the bug' thing.

I want to thank you guys for helping me solve the problem. I really appreciate it <3

- Balt
 

vypur85

Hibernate
Reaction score
803
Though problem solved but, 'Waits' do not work properly in 'Integer A' or 'Integer B' loops. Use custom variable integer instead.
 

Baltazhar

Active Member
Reaction score
55
How do you mean using a variable in the loop? Instead of 'Wait .10 seconds', then 'Wait Real_A seconds' - Where Real_A is set by trigger/default to a value of 0.10?

I'll try to do some more experimenting. If it can make one target entangle, by God it should be able to do the others somehow...
 

Kazuga

Let the game begin...
Reaction score
110
Code:
For each (Your integer variable) from 1 to 10, do (Actions)
    Loop - Actions
This is found just below "For each integer B".
The bugs that can appear unless you use your own integer is that the other loops that is runed at the same time can start run this loop and your loop run that loop so that they don't run the amount of times they should, they could also bug up so none of them run etc... This is atleast the bugs that I have faced when map making.
 

Baltazhar

Active Member
Reaction score
55
Ah okay, never knew that. Thanks for the information.
I tried swapping the 0.10 seconds with a Real_Variable with the 0.10 value, without success unfortunately.

I have previous had some problems with the 'Target unit of ability being cast', with the trigger not remember who the target was all the way through the trigger. Even though there was no Wait functions in them. That's why I put the variable in the trigger to begin with.
And I just thought "What if it's the same problem with 'Casting Unit'?". So I made a variable, stored the Casting Unit in it, and used that reference throughout the trigger. And that seemed to do the problem. I don't know if the 'Casting Unit' reference gets screwed up if another unit casts a spell between the original spell was cast, and the reference used.

None the less, every works as intended.

Thanks to everyone for the help, rep all around.
If you should need the ability in your map, feel free to use it :)

Choking Vines (Entangle)
Code:
Choking Vines
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Choking Vines 
    Actions
        Set ChokingVinesPreviousTarget = (Target unit of ability being cast)
        Set ChokingVinesCaster = (Casting unit)
        For each (Integer A) from 1 to (((Level of Choking Vines  for ChokingVinesCaster) x 5) - 1), do (Actions)
            Loop - Actions
                Wait 0.10 seconds
                Set Temp_Point = (Position of ChokingVinesPreviousTarget)
                Set Temp_Group = (Units within 150.00 of Temp_Point matching (((Matching unit) belongs to an enemy of (Owner of ChokingVinesCaster)) Equal to True))
                Unit Group - Pick every unit in Temp_Group and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Or - Any (Conditions) are true
                                    Conditions
                                        ((Picked unit) is dead) Equal to True
                                        ((Picked unit) has buff Choking Vines) Equal to True
                            Then - Actions
                                Unit Group - Remove (Picked unit) from Temp_Group
                            Else - Actions
                Set ChokingVinesTarget = (Random unit from Temp_Group)
                Unit - Create 1 Choking Vines (unit) for (Owner of ChokingVinesCaster) at Temp_Point facing Default building facing degrees
                Unit - Add Choking Vines (dummy) to (Last created unit)
                Unit - Set level of Choking Vines (dummy) for (Last created unit) to (Level of Choking Vines  for ChokingVinesCaster)
                Unit - Order (Last created unit) to Night Elf Keeper Of The Grove - Entangling Roots ChokingVinesTarget
                Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                Set ChokingVinesPreviousTarget = ChokingVinesTarget
        Custom script:   call RemoveLocation (udg_Temp_Point)
        Custom script:   call DestroyGroup (udg_Temp_Group)

Works perfectly and doesn't leak as far as I know.
God I <3 this forum :thup:

- Baltazhar

EDIT: Sorry vypur, I must wait before I can give you more reputation. The amount of appreciation I can give however, has no limit ;)
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
Haha,
I have a spell basically identical to this. Which I made recently. o_O
Felt like posting it if you want to see it:

Code:
Entangling Roots
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Entangling Roots 
    Actions
        Set p1 = (Position of (Triggering unit))
        Set p2 = (Target point of ability being cast)
        Set ug = (Units within 200.00 of p2 matching ((((Owner of (Matching unit)) is an enemy of (Triggering player)) Equal to True) and (((Matching unit) is alive) Equal to True)))
        For each (Integer i) from 1 to ((Level of Entangling Roots  for (Triggering unit)) x 5), do (Actions)
            Loop - Actions
                Set u = (Random unit from ug)
                Unit - Create 1 Dummy for (Triggering player) at p1 facing p2
                Unit - Add a 2.50 second Generic expiration timer to (Last created unit)
                Unit - Add Entangling Roots (Dummy) to (Last created unit)
                Unit - Set level of Entangling Roots (Dummy) for (Last created unit) to (Level of Entangling Roots  for (Triggering unit))
                Unit - Order (Last created unit) to Night Elf Keeper Of The Grove - Entangling Roots u
                Unit Group - Remove u from ug
                Wait 0.10 game-time seconds
        Custom script:   call DestroyGroup(udg_ug)
        Custom script:   call RemoveLocation(udg_p2)
        Custom script:   call RemoveLocation(udg_p1)
 

vypur85

Hibernate
Reaction score
803
Edit this:
Code:
        For each [B](Integer A)[/B] from 1 to (((Level of Choking Vines  for ChokingVinesCaster) x 5) - 1), do (Actions)
            Loop - Actions
                Wait 0.10 seconds

To this:
Code:
        For each Integer [B]Custom_Integer[/B] from 1 to (((Level of Choking Vines  for ChokingVinesCaster) x 5) - 1), do (Actions)
            Loop - Actions
                Wait 0.10 seconds

What we meant was changing the Integer A into something else. Something like what Adam did in his trigger. Use a custom integer instead of the default Integer A. Though the trigger works now, but in future problems will definately occur because of overlapping of Integer A, as mentioned by Kazuga.
 

Baltazhar

Active Member
Reaction score
55
Ooooh... That's what it meant. Ofcourse, didn't even occur to me. Never used other integers than the standard ones, which definately will be a problem with all the custom abilities I have running.

Would you guys then suggest making a custom integer for each of the custom abilities using For each integer functions? - That would make it almost fail-proof, except on the rare occasions where more people have the same hero (planning on implementing a Mirror Match mode), but then people would have to cast the ability within 2 seconds of eachother... Hmm, which is not acceptable with like 4 of the same hero (although that is very unlikely, it's still possible).

Hehe Adam, pretty wierd we both got the same idea. Nice though, cuz it looks bloody awesome :)
And we can help eachother, like that Integer i you have used. I would suggest you to filter out already entangled units with the Unit Group - Remove (Picked unit) from Temp_Group function.

EDIT: Awarded you rep Adam, as a friendly gesture :) Still can't award you vypur :(
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
Re-Read my code... :p
I have removed the unit xD

Oh, unless you mean from a seperate cast?
That sounds like a good suggestion thanks! :)

If you know how, use local integers. It saves you having loads of globals.
You don't need a custom integer for each spell. It should only be a problem on the ones that have waits inside the loop function.

(+rep in return)
 

Baltazhar

Active Member
Reaction score
55
Ah ofcourse, all integer loops without waits happens instantaneously. Thanks for the advice mate, saves me a buck load of bugs later on :)
 

Curo

Why am I still playing this game...?
Reaction score
109
Not meaning to try and revive my dead thread, but your spell here seems to function a lot like my Chain Water Elemental spell was supposed to work. Unfortunately I could never get it working. Nobody seemed to want to help me out at the time, so I'm going to take this opportunity to link up my thread and maybe some of you can look at it.

Chain Water Elemental

I'm going to thoroughly look through this thread for anything that can help me. You don't know how much torment this spell caused me, and it would be a godsend if someone could help me get it working. Again, I don't want to hijack your thread, I just couldn't help but see the similarity in the way these two spells function.
 

Baltazhar

Active Member
Reaction score
55
Ah it's no problem mate, I got my spell working already, so the posts in here from now on are just chitchat :)

I'll take a look at your spell...
 
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