Ability Problem

HG-Bonfire

New Member
Reaction score
22
OK i decided to try and make a Puppeteer hero which I had thought of on this thread , and his Ulti spell can take control of 10 units around the hero aslong as he keeps channeling. Heres the triggers I used for it.

Code:
Pulling Strings
    Events
        Unit - A unit Begins channeling an ability
    Conditions
        (Ability being cast) Equal to Pulling Strings 
        (Unit-type of (Casting unit)) Equal to Puppeteer
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Pulling Strings  for (Casting unit)) Equal to 1
            Then - Actions
                Set Puppeteer = (Casting unit)
                For each (Integer A) from 1 to 10, do (Actions)
                    Loop - Actions
                        Player Group - Pick every player in (All enemies of (Owner of Puppeteer)) and do (Actions)
                            Loop - Actions
                                Set Units_under_Control[(Integer A)] = (Random unit from (Units within 1000.00 of (Position of Puppeteer) matching ((((Matching unit) is A Hero) Equal to False) and ((Owner of (Matching unit)) Equal to (Picked player)))))
                        Lightning - Create a Magic Leash lightning effect from source (Position of Puppeteer) to target (Position of Units_under_Control[(Integer A)])
                        Set Lightning_Effect[(Integer A)] = (Last created lightning effect)
                        Trigger - Turn on Pulling Strings Lightning Effect <gen>
                        Unit - Change ownership of Units_under_Control[(Integer A)] to (Owner of (Casting unit)) and Retain color
            Else - Actions
                Do nothing

and
Code:
Pulling Strings Lightning Effect
    Events
        Time - Every 0.10 seconds of game time
    Conditions
    Actions
        Lightning - Move Lightning_Effect[1] to source (Position of Puppeteer) and target (Position of Units_under_Control[1])
        Lightning - Move Lightning_Effect[2] to source (Position of Puppeteer) and target (Position of Units_under_Control[2])
        Lightning - Move Lightning_Effect[3] to source (Position of Puppeteer) and target (Position of Units_under_Control[3])
        Lightning - Move Lightning_Effect[4] to source (Position of Puppeteer) and target (Position of Units_under_Control[4])
        Lightning - Move Lightning_Effect[5] to source (Position of Puppeteer) and target (Position of Units_under_Control[5])
        Lightning - Move Lightning_Effect[6] to source (Position of Puppeteer) and target (Position of Units_under_Control[6])
        Lightning - Move Lightning_Effect[7] to source (Position of Puppeteer) and target (Position of Units_under_Control[7])
        Lightning - Move Lightning_Effect[8] to source (Position of Puppeteer) and target (Position of Units_under_Control[8])
        Lightning - Move Lightning_Effect[9] to source (Position of Puppeteer) and target (Position of Units_under_Control[9])
        Lightning - Move Lightning_Effect[10] to source (Position of Puppeteer) and target (Position of Units_under_Control[10])

The problem is that the trigger is only taking over units belonging to player 2, even though I have put in several more enemy players of the Puppeteer. Anybody see whats wrong?
 
E

Eilhal

Guest
it looks like it should work... are you sure that they are all enemies of the puppeteer :p lol... I really have no clue what the problem may be
 

Daelin

Kelani Mage
Reaction score
172
Begins channeling an ability works just like begins casting an ability. Use "Starts the effect of an ability".

Use (Triggering Unit) instead of (Casting Unit). It is faster.

(Integer A) is dangerous because if another spell uses as well, the two may get messed up if cast at the same time.

And your problem is obvious. Just check how this piece of code works:
Code:
For each (Integer A) from 1 to 10, do (Actions)
                    Loop - Actions
                        Player Group - Pick every player in (All enemies of (Owner of Puppeteer)) and do (Actions)
                            Loop - Actions
                                Set Units_under_Control[(Integer A)] = blahblah

Well... The loop will be executed 10 times, there's no doubt. But the Pick up every unit picks all player I do not in which order, and for each player it assigns an unit to Unit_under_Control[x]. Problem is that if all the units are stored in the same variable, then only the unit of the last picked player will be taken. Clear? ;)

~Daelin
 

HG-Bonfire

New Member
Reaction score
22
Umm im sorry but im not sure what you're talking about, could you explain in a bit more detail?

and as for the integer A and stuff, it doesnt matter because there will only be 1 of the hero.
 
M

Masterfrog

Guest
I think what he means is because you got a loop in a loop, as long as integer A is 1, it will be fine, but when it loops it the second time, i.e. integer A is 2, it does the same thing over again, wich overwrite what it did do when it was 1, i.e. teh first time. and it will keep overwriting it 10 times. So as far as I can see that for each integer A loop actually does nothing.
 

Daelin

Kelani Mage
Reaction score
172
No... actually it's something like this.

Consider that you have nine footmen, three for player red, three for player blue, and three for player teal that may be picked by the trigger. You are player purple (let's consider that no other player exists).

Now, let's see how the trigger works (logically), with the loop above:

- (Integer A) = 1
- Player 16 is picked.
- Units_under_Control[1] = none //no such unit exists
- Player 15 is picked
- Units_under_Control[1] = none //no such unit exists
[...] //so on
- Player 4 (purple) is picked
- Units_under_Control[1] = none //you can't picked allied unit
- Player 3 (teal) is picked
- Units_under_Control[1] = footman
- Player 2 (blue) is picked
- Units_under_Control[1] = footman
- Player 1 (red) is picked
- Units_under_Control[1] = footman

In the end, only a red footman is picked. Why? Because all the units are stored in the same variable. But a variable can store only a single value. The value currently stored in a variable, is actually the last value. In this case, the read footman.

Of course, I am unaware of how players are picked. I am thinking that if the last player picked is the owner of the caster for example, then in the end, no unit will be stored in the variable.

Buggy code! Bad algorithm!

~Daelin
 

HG-Bonfire

New Member
Reaction score
22
actually i figured out the problem, it had apsolutly nothing to do with the triggers. For some reason, when i test the game, only player 2 is listed as a computer, I have to actually open the game from wc3 and set the other computers to computer, they were on Open for some reason, and that meant they were the only enemy of the puppeteer

[EDIT]
Ok even after setting the fixed player settings in forces, now it only selects player 5, which is very strange, Is there a way to fix this?
 
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