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

[Solved] AOE exp gain spell/GUI/MUI/updating WE

Status
Not open for further replies.
Level 21
Joined
Mar 29, 2020
Messages
1,237
  • MoR
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Monologue of Righteousness
    • Actions
      • Set caster = (Casting unit)
      • Set AoeTargets = (Units within 500.00 of (Position of caster) matching ((Owner of (Matching unit)) Not equal to (Owner of caster)))
      • Set abilitylevel = (Level of (Ability being cast) for (Triggering unit))
      • Unit Group - Pick every unit in AoeTargets and do (If (((Picked unit) belongs to an enemy of (Owner of caster)) Equal to True) then do (Hero - Disable experience gain for (Picked unit)) else do (Do nothing))
      • Wait 5.00 game-time seconds
      • For each (Integer abilitylevel) from 1 to 3, do (Wait 5.00 seconds)
      • Unit Group - Pick every unit in AoeTargets and do (Hero - Enable experience gain for (Picked unit))
      • Custom script: call DestroyGroup(udg_AoeTargets)

I read some tutorials, but still don't have a deep enough understanding to be sure. thanks!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
Edit: you're leaking a Point when you use position of caster. Instead, set position of caster as a Point variable and remove it using call RemoveLocation after you're done referencing it.

The Unit Group doesn't leak as long as the ability isn't used again while a previous cast is still running.

Also the loop for the wait is very odd. Use arithmetic and do this instead:
Wait 5.00 + (5.00 × Real(abilitylevel))

Managing arithmetic is easy once you get the hang of it.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
Any unit. The spell will straight up break if it's used more than once in short succession. This is because you're using a Wait, and during this Wait the variables can change to something else, creating leaks and breaking the spell.

Think about it.
Unit 1 casts the spell, the Wait starts running.

5.00 seconds later, Unit 2 casts the spell. All of the variables have now changed to work for Unit 2's ability.

Most importantly, the Unit Group that you reference after the Wait.

So after Unit 1's Wait is finished, it will pick every unit in Unit 2's Unit Group, instead of Unit 1's Unit Group.

Not only that, the Unit Group will be destroyed, so Unit 2's trigger won't be able to pick every unit in the group after their Wait has finished.

Solution:
Make the spell MUI using a Unit Indexer or Dynamic Indexing. Links in my signature.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
In my opinion:

Unit Indexer = Most limiting but easiest to use. Might not work for this type of spell.

Hashtable allows for the most flexibility.

Dynamic Indexing is pretty much the same as the Hashtable.

I'd use Dynamic Indexing just as a personal preference.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
The very design of your spell is tricky because you're toggling Exp Gain on and off. This will bug out with multiple casts on the same target.

A fix: You should use an Integer (ExpGainCounter for example) to keep track of how many times a unit has been targeted by this spell. Increase it by 1 when a unit gets targeted, and decrease it by 1 at the end of the Wait. Then instead of setting Exp Gain on after the Wait, put an if then else:

If ExpGainCounter equal to 0 THEN turn Exp Gain on.

This way Exp Gain will only ever be turned on when the very last spell affecting the unit finishes.

I'll create an example trigger when I get home later.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
Edit: Uploaded v2. Fixed some bugs and simplified it.

It uses Bribe's Unit Indexer -> GUI Unit Indexer 1.4.0.0
  • Cast MoR
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Put your ability being cast here!!!
    • Actions
      • Set VariableSet TempPoint[1] = (Position of (Triggering unit))
      • -------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 500.00 of TempPoint[1].) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
              • ((Picked unit) belongs to an enemy of (Triggering player).) Equal to True
            • Then - Actions
              • -------- If the Picked Unit isn't in MoR_Group then add it to it --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in MoR_UnitGroup.) Equal to False
                • Then - Actions
                  • Unit Group - Add (Picked unit) to MoR_UnitGroup
                • Else - Actions
              • -------- --------
              • -------- We increase the MoR_Counter for the picked unit - If it's equal to 1 then we know it's safe to Disable the Exp Gain --------
              • Set VariableSet CV = (Custom value of (Picked unit))
              • Set VariableSet MoR_Counter[CV] = (MoR_Counter[CV] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MoR_Counter[CV] Equal to 1
                • Then - Actions
                  • Hero - Disable experience gain for (Picked unit).
                • Else - Actions
            • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation (udg_TempPoint[1])
      • -------- --------
      • Wait (5.00 + (5.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))) game-time seconds
      • -------- --------
      • Unit Group - Pick every unit in MoR_UnitGroup and do (Actions)
        • Loop - Actions
          • -------- When MoR_Counter reaches 0 we know that the unit is free of any MoR casts and can enable it's Exp Gain again --------
          • Set VariableSet CV = (Custom value of (Picked unit))
          • Set VariableSet MoR_Counter[CV] = (MoR_Counter[CV] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MoR_Counter[CV] Equal to 0
            • Then - Actions
              • Hero - Enable experience gain for (Picked unit).
              • Unit Group - Remove (Picked unit) from MoR_UnitGroup.
            • Else - Actions
 

Attachments

  • MoR Example 2.w3m
    22.6 KB · Views: 13
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
meaning that I need that trigger for this to work, right?

thanks a ton man, haven't tried this out yet but looks great!

I fixed some bugs and uploaded version 2. Check my above post!

And correct, you'll need to copy the Unit Indexer folder into your map. You can just copy and paste it from my map OR download the Unit Indexer map from that link I posted, open it, and copy the "Unit Indexer' folder from the Trigger Editor and paste it into your map.

IMPORTANT, before importing it, if you haven't already done so, go into File/Preferences/General (in the World Editor) and check on "Automatically create unknown variables...". While you're there I recommend turning on "Allow negative Real values", it can come in use in the future.

Note that if you already have a Unit Indexer (you probably don't) then you won't need to import this one.

Also, be wary that if any of your other triggers use Custom Value it will conflict with the Unit Indexer. I can help you fix those triggers if that's the case though most people don't use Custom Value so it's probably not an issue.
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
Also, be wary that if any of your other triggers use Custom Value it will conflict with the Unit Indexer. I can help you fix those triggers if that's the case though most people don't use Custom Value so it's probably not an issue.

Is it safe to assume that if I don't know what that means I haven't used it? :hohum: the only custom code i have besides this is deleting variables...

also for some reason I can't open your map, so i'll just reconstruct the trigger per specifications. i'll learn more that way anyways...

also when i use variables like TempPoint - should i try to have a brand new variable for each different trigger(that isn't instantaneous) that needs a tempppoint, or will the indexer deal with that too?

thanks again!
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
  • Set VariableSet CV = (Custom value of (Picked unit))
  • Set VariableSet MoR_Counter[CV] = (MoR_Counter[CV] + 1)

what kind of variable is MoR_Counter[CV]? - I'm assuming the square parentheses are a built in function that makes it relate to the value of variable "CV" but can't figure out how to recreate it....

(I know you sent me a functional version but i can't get the map to load...:confused:2)
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
MoR_Counter = Integer (Array).
CV = Integer.

CV is used as a shortcut so you don't have to put in "custom value of unit" over and over again. It's just there to make your life easier.

You should look into how Unit Indexers work. It's actually very simple. And look up "Custom Value", once you get how that works the Unit Indexer makes more sense.

And you can only put Integers in an Index [ ]
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
Yeah, that's fine. I originally had 2 Points in the trigger so instead of creating 2 separate variables I used one variable with an Array.

It helps keep your map organized and less cluttered by using these "Temporary" variables along with Arrays. The key is to know when to use them so that they won't leak. Points, Unit Groups, Player Groups, and Special Effects are the main culprits for leaks. Integers, Reals, and Booleans on the other hand don't leak so you can use Temp versions of them throughout your triggers safely. Keep in mind that using Waits and other delays can cause problems since this opens up the opportunity for other triggers to change the values of these variables.

But the general rule of thumb is: As long as you're removing TempPoint (or another leakable variable) before it's created again then it won't leak.

And to answer your question about custom value. yes, that's a safe assumption. If you don't know what custom value is then you probably have nothing to worry about, lol.
 
Last edited:
Level 16
Joined
May 2, 2011
Messages
1,345
not sure... where does it say?

when you open your WC3 you see a number in the bottom right. it could be one of the following
1.32
1.31
1.29
1.26
1.24

Your WE version should be the same as your WC3 version
maybe you have a different version than that of uncle and thats why you were not able to open his map. maybe there is another reason.
 
Level 16
Joined
May 2, 2011
Messages
1,345
1.20:gg:

is that an easy fix? and will it mess up my maps?

usually new versions can open old versions but not the other way around. I dont have 1.20. I only have 1.24 1.26 and 1.31

I dont advise you to update your game though. if you really want to update, please do backup your current copy.


there is another option which you can find in dota utilities, a programm (just zip file) named WC3 version switcher. it can switch between 1.24 to 1.26

always have a backup of your game just in case anything happen. one on your PC and another backup in external flash or hard disk.
 
Level 16
Joined
May 2, 2011
Messages
1,345
Whats wrong with 1.20?

If there is any problem with older versions it would be if you wanted to use some trigger function which was introduced in newer versions. I am not expert on trigger updates and changelog, but I doubt there are many changes that will affect your map.


The older versions might have advantage though. When you make your map with 1.20, everyone should be to play your map AFAIK, but if you make your map with new 1.32, there is a chance other game versions will not be able to play your map.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,579
They introduced a lot of cool features in recent patches. New UI stuff, the Field values that let you manipulate Object Editor data through triggers, etc...

If everyone updated then it would make my life 100x easier, lol. Pain in the ass trying to help people when their editor is missing features.
 
Level 16
Joined
May 2, 2011
Messages
1,345
If everyone updated then it would make my life 100x easier, lol. Pain in the ass trying to help people when their editor is missing features.

IF
But you cannot assume everyone have new update, and life is never as easy as you'd want it to be. I care that my map is playable by most people possible so it is better for me and for @Ender Wiggins to stay at our patches.

I rather have 5k more downloads instead of 2 or 3 new "cool" features

also IIRC there is no campaign in the new patch. so its useless to make my campaign using it.

but I guess im going slightly off-topic :p
 
Status
Not open for further replies.
Top