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

how do I make this spell MUI?

Status
Not open for further replies.
Level 12
Joined
Jan 13, 2008
Messages
559
Code:
Dark Meteor
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Dark Meteor 
    Actions
        Special Effect - Create a special effect at (Position of (Target unit of ability being cast)) using DarknessMeteor.mdx
        Wait 0.80 seconds
        Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 20 damage of attack type Spells and damage type Normal

I can't think of anything that would work :/ even tho I am sure its pretty easy probably
 
[trigger][/trigger] not [code][/code]

  • Dark Meteor
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Dark Meteor
    • Actions
      • Set DM_Index = (DM_Index + 1)
      • Set DM_Caster[DM_Index] = (triggering unit)
      • Set DM_Target[DM_Index] = (Target unit of ability being cast)
      • Set DM_TempLoc = (Position of (DM_Target[DM_Index]))
      • Special Effect - Create a special effect at DM_TempLoc using DarknessMeteor.mdx
      • Set DM_Fx[DM_Index] = (last created special effect)
      • Trigger - turn on <DM Loop>
      • Custom script: call RemoveLocation(udg_DM_TempLoc)
remove your leaks. Seriously, do it before it is too late :(

  • DM Loop
    • Events
      • Time - Every 0.08 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to DM_Index do
        • Actions - Loop
          • Unit - Cause DM_Caster[(Integer A)] to damage DM_Target[(Integer A)], dealing 20 damage of attack type Spells and damage type Normal
      • Trigger - Turn off (this trigger)
You could also deindex it, but start with that. Also, read the tutorial Karzama posted. It's what's up.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Or, because fuck indexing, use a tiny bit of jass. The following trigger is MUI.
(inaccurate though)

  • Dark Meteor
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Dark Meteor
    • Actions
      • Custom script: local unit udg_unit
      • Set unit = (Target unit of ability being cast)
      • Set l = (Position of unit)
      • Special Effect - Create a special effect at l using DarknessMeteor.mdx
      • Custom script: call RemoveLocation(udg_l)
      • Wait 0.80 seconds
      • Unit - Cause (Triggering unit) to damage unit, dealing 20 damage of attack type Spells and damage type Normal
 
Level 7
Joined
Nov 19, 2015
Messages
283
Or, because fuck indexing, use a tiny bit of jass. The following trigger is MUI.
(inaccurate though)

  • Dark Meteor
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Dark Meteor
    • Actions
      • Custom script: local unit udg_unit
      • Set unit = (Target unit of ability being cast)
      • Set l = (Position of unit)
      • Special Effect - Create a special effect at l using DarknessMeteor.mdx
      • Custom script: call RemoveLocation(udg_l)
      • Wait 0.80 seconds
      • Unit - Cause (Triggering unit) to damage unit, dealing 20 damage of attack type Spells and damage type Normal

How is that MUI? The will be the same after the wait however the target will change if another unit casts withing the 0.8 seconds
 
How is that MUI? The will be the same after the wait however the target will change if another unit casts withing the 0.8 seconds

It just is ... you know whay? Because Chaosy has over 1600 rep points, that's why. You don't get rep for being wrong (often).

And, also because he set the local unit.

However, mine is better because it has no wait ... unless Chaosy says otherwise, then he is right, because he just is.
 
Level 7
Joined
Nov 19, 2015
Messages
283
I'm trying to make all my spells MUI now.

I guess any spells that use a wait, you can just add in the local thingy?
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
@Legal
ahahaah.
I am wrong many times, but when I am uncertain I (almost) always include an 'I think' or something. In fact I believe that I am mostly wrong in theoretical questions if anything.
It is indeed very rare that I post a trigger that does not work.

@kingwong
It's MUI thanks to the local yeah but you can't just copy and paste that local and everything becomes MUI and you can use waits freely.
Here is the method I use.
http://www.hiveworkshop.com/forums/spells-569/local-udg_-248534/?prev=search=shadowing&d=list&r=20

@Radicool
Exactly.
 
Local variable shadowing will break if you optimize your map and works in limited circumstances. The variable will not be treated as a local if you use it within an if/else block or "pick all units" block.

Using http://www.hiveworkshop.com/forums/spells-569/gui-spell-system-v1-0-0-0-a-273415/, this spell looks like this:

  • Config Dark Meteor
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set Spell__Ability = Dark Meteor
      • Set Spell__Trigger_OnCast = Dark Meteor
      • Set Spell__Trigger_OnLoop = Dark Meteor Damage
      • Trigger - Run Spell Event Registry <gen> (ignoring conditions)
  • Dark Meteor
    • Events
    • Conditions
    • Actions
      • Set Spell__Time = 0.8
      • Special Effect - Create a special effect at Spell__TargetPoint using DarknessMeteor.mdx
      • Special Effect - Destroy (Last created effect)
  • Dark Meteor Damage
    • Events
    • Conditions
    • Actions
      • Unit - Cause Spell__Caster to damage Spell__Target, dealing 20 damage of attack type Spells and damage type Normal
      • Trigger - Run Spell Index Destroy <gen> (ignoring conditions)
 
Level 12
Joined
Jan 13, 2008
Messages
559
[trigger][/trigger] not [code][/code]


remove your leaks. Seriously, do it before it is too late :(



You could also deindex it, but start with that. Also, read the tutorial Karzama posted. It's what's up.

Thank you but for some reason the unit doesn't take any damage. Here is what I've done:

  • Dark Meteor Loop
    • Events
      • Time - Every 0.80 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to DM_Index, do (Actions)
        • Loop - Actions
          • Unit - Cause DG_Caster[(Integer A)] to damage DG_Target[(Integer A)], dealing DM_Damage[(Integer A)] damage of attack type Hero and damage type Normal
      • Trigger - Turn off (This trigger)
  • Dark Meteor
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Dark Meteor
    • Actions
      • Set DM_Index = (DM_Index + 1)
      • Set DM_Caster[DM_Index] = (Triggering unit)
      • Set DM_Target[DM_Index] = (Target unit of ability being cast)
      • Set DM_TempLoc = (Position of DM_Target[DM_Index])
      • Set DM_Damage[DM_Index] = (player_spelldamage[((Player number of (Owner of (Triggering unit))) - 1)] x 1.80)
      • Special Effect - Create a special effect at DM_TempLoc using DarknessMeteor.mdx
      • Set DM_sfx = (Last created special effect)
      • Trigger - Turn on Dark Meteor Loop <gen>
      • Custom script: call RemoveLocation(udg_DM_TempLoc)
Btw, why is it enough to create arrays with a size of 1 only?
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Local variable shadowing will break if you optimize your map and works in limited circumstances. The variable will not be treated as a local if you use it within an if/else block or "pick all units" block.

Oh yeah, I knew about unit groups due ForGroup using another function.
But do if blocks to that as well? I mean there are if whatever == true then... there is no need to use a function to return a value :-/
 
Nordmar, that indexing is primitive and stops being MUI after a large number of indices has been reached. Use this indexing method I listed here: http://www.hiveworkshop.com/forums/...8/how-do-i-make-spell-mui-273454/#post2765468 or simply a working indexing method.

Don't modify the size of arrays in variable editor as too big arrays will crash the main thread and prevent your game from loading. Size 1 arrays are fine. It doesn't limit the size, it just influences how many indices are initialized beforehand.

Oh yeah, I knew about unit groups due ForGroup using another function.
But do if blocks to that as well? I mean there are if whatever == true then... there is no need to use a function to return a value :-/

GUI if-blocks are sent to a function at the top of the trigger's script space, instead of in JASS where it is inlined within the triggeraction's function. Local variable shadowing is interesting, but it's not good practice. Better to use full-on JASS if you want to use locals after a wait.
 
Level 12
Joined
Jan 13, 2008
Messages
559
Nordmar, that indexing is primitive and stops being MUI after a large number of indices has been reached. Use this indexing method I listed here: http://www.hiveworkshop.com/forums/...8/how-do-i-make-spell-mui-273454/#post2765468 or simply a working indexing method.

How big must the number be to stop working? 8192?
I will check the GUI System out, thank you. Btw how does this other solution work anyway (the one posted by Legal Ease). Because let's say I am the 10th player casting the ability, so Index is at 10. Now the run trigger will run the loop 10 times so deal 10 times the damage its supposed to deal or am I missing smthg?

/e: i just saw ur system has not been approved yet..
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
How big must the number be to stop working? 8192?
8192 instances, or array 0-8191. How often do you think your map would reach 8192 instances of one spell at the same time? xD


I will check the GUI System out, thank you. Btw how does this other solution work anyway (the one posted by Legal Ease). Because let's say I am the 10th player casting the ability, so Index is at 10. Now the run trigger will run the loop 10 times so deal 10 times the damage its supposed to deal or am I missing smthg?
That's not how it works. Each index of the loop is a UNIQUE instance.


/e: i just saw ur system has not been approved yet..
It has been basically approved in the Lab. The only reason it says that is because another moderator hasn't taken a full look at it. You would only have to actually worry about something not being approved if it says Rejected or Needs Fixed.
 
1) Try dealing fixed damage, like 50, instead of referencing the damage from the other variable.

2) The timed trigger is not going to wait 0.8 seconds. It will be an average of 0.4 seconds.

There is a more serious problem: the next time this is cast, the loop will have all previous casters damage all previous targets. As I said, you'll need to use a real indexing method.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
I still don't really get it.

var index = 10

so the loop goes: For each IntegerA from 1 to 10 do action

so why would it only run once?
Because that is how loops work. They "loop" through each integer once.


And any idea why the spell doesnt deal any damage in my previous posted trigger?
Can you post the trigger where you initialize player damage? I have a really big idea of why they aren't being damage, but I must first see this trigger.
 
Level 12
Joined
Jan 13, 2008
Messages
559
Because that is how loops work. They "loop" through each integer once.



Can you post the trigger where you initialize player damage? I have a really big idea of why they aren't being damage, but I must first see this trigger.

Ah right..totally logic. I just was too tired before to get it ^^ but then the problem is like Bribe stated that the previous saved caster deals to the previous saved enemy damage again. How can this even be a solution? ^^ thats very bad. I think I just put the variable to null after it is used.

And there is a variable called player_spelldamage[10] with a starting value of 120.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Why? If I print the array it shows correctly 120.

What is the point of making something an array if they are all going to have the same value lol. It's also much easier to reference and set variables in trigger functions instead of having to go into the Variable editor.


Anyway, this line is causing the problem:
  • Set DM_Damage[DM_Index] = (player_spelldamage[((Player number of (Owner of (Triggering unit))) - 1)] x 1.80)]

Specifically this part: Player number of (Owner of (Triggering unit)) - 1. I'm assuming you are testing the map as Player Red, who will have a Player number of 1. Since you are subtracting 1 (I actually wonder why you even subtract it in the first place), that makes the array element 0.

Now take a look at your loop:
  • For each (Integer A) from 1 to DM_Index, do (Actions)
    • Loop - Actions
      • Unit - Cause DG_Caster[(Integer A)] to damage DG_Target[(Integer A)], dealing DM_Damage[(Integer A)] damage of attack type Hero and damage type Normal

Integer A starts at 1, meaning that Damage[0] doesn't exist to the loop.
 
Level 12
Joined
Jan 13, 2008
Messages
559
What is the point of making something an array if they are all going to have the same value lol. It's also much easier to reference and set variables in trigger functions instead of having to go into the Variable editor.


Anyway, this line is causing the problem:
  • Set DM_Damage[DM_Index] = (player_spelldamage[((Player number of (Owner of (Triggering unit))) - 1)] x 1.80)]

Specifically this part: Player number of (Owner of (Triggering unit)) - 1. I'm assuming you are testing the map as Player Red, who will have a Player number of 1. Since you are subtracting 1 (I actually wonder why you even subtract it in the first place), that makes the array element 0.

Now take a look at your loop:
  • For each (Integer A) from 1 to DM_Index, do (Actions)
    • Loop - Actions
      • Unit - Cause DG_Caster[(Integer A)] to damage DG_Target[(Integer A)], dealing DM_Damage[(Integer A)] damage of attack type Hero and damage type Normal

Integer A starts at 1, meaning that Damage[0] doesn't exist to the loop.

I use an array because the values change in the game obviously. And yes that was the problem.

Stupid mistake. And @Bribe: the problem that the previous units are gonna damage again is easily fixed as you can see here: http://www.hiveworkshop.com/forums/...orials-279/visualize-dynamic-indexing-241896/
 
Level 12
Joined
Jan 13, 2008
Messages
559
Ok, I just realised a big problem:

  • Dark Meteor Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer DM_loop_integer) from 1 to DM_Index, do (Actions)
        • Loop - Actions
          • Set DM_count_tmp[DM_loop_integer] = (DM_count_tmp[DM_loop_integer] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DM_count_tmp[DM_loop_integer] Greater than or equal to 36
            • Then - Actions
              • Unit - Cause DM_Caster[DM_loop_integer] to damage DM_Target[DM_loop_integer], dealing DM_Damage[DM_loop_integer] damage of attack type Hero and damage type Normal
              • Game - Display to (All players) for 0.50 seconds the text: Ability ends, Index...
              • Game - Display to (All players) for 0.50 seconds the text: (Index: + (String(DM_Index)))
              • Set DM_Index = (DM_Index - 1)
              • Set DM_loop_integer = (DM_loop_integer - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DM_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
The spell works completely fine for 1 player BUT it does not for 2 players. Player 1 casts DarkMeteor and just right after Player 2 casts DarkMeteor aswell. The output as soon as Player 1 finishes the ability is:

Ability ends, Index: 2
Ability ends, Index: 1

And when shortly after the ability of player 2 ends, it deals no damage. How and why?

/e: i forgot to set this line:
  • Set DM_count_tmp[DM_loop_integer] = DM_count_tmp[DM_Index]
 
Status
Not open for further replies.
Top