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

[Solved] Need help making this spell MUI

Status
Not open for further replies.
Level 2
Joined
Aug 9, 2016
Messages
9
Hi guys, I'm working on this spell and trying to make it MUI but I have no idea how to use hashtables, please can you help me? Also any suggestion to make my triggers better would be helpful. (I'm not an expert using vJass ect. even WE triggers, just know the basics)

OK! The Spell is basically summoning a Faerie Dragon companium which is invunerable and unselectable (Locust abillity). It follows and moves randomly around the caster, it can cast abillitys at certain cooldowns at the enemy the caster is attacking. This spell is inspired in Emerald's Summon Gawain from HON.

Here is the codes

  • Faerie ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- 0.05 x Value = Fairy Fire Abillity Cooldown --------
      • Set FireBoltCooldown = 200
      • -------- -------- --------
      • -------- 0.05 x Value = Time between move order (less than 10 it may bug/wierd animation) -----
      • Set MoveFrequency = 10
      • -------- -------- --------
      • -------- Area to fairy move around the caster --------
      • Set MoveArea = 600.00
      • -------- -------- --------
      • -------- Range limit between caster and fairy, to cast Fire Fairy --------
      • Set DistanceFairyFire = (MoveArea + 600.00)
      • -------- -------- --------
      • -------- Distance limit to blink --------
      • Set DistanceBlink = (MoveArea + 1000.00)
      • -------- -------- --------
      • -------- Range check to decides if it moves at a random point or follow --------
      • Set FollowRange = 350.00
      • -------- -------- --------
      • -------- Effects --------
      • -------- Blink Effect --------
      • Set BlinkEffect = Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
      • -------- -------- --------
      • -------- Summon Effect --------
      • Set SummonEffect = Abilities\Spells\NightElf\FaerieDragonInvis\FaerieDragon_Invis.mdl
      • -------- -------- --------
      • -------- Permanent Effect --------
      • Set AttachedEffect = war3mapImported\Phoenix_Missile.mdl
  • Faerie Summon
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Fire Fairy Dragon (Unit/Caster)
    • Actions
      • Unit - Kill F_Fairy
      • Trigger - Turn off Faerie Loop <gen>
      • Set F_AbillityCount = (F_AbillityCount - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • F_AbillityCount Less than or equal to 0
        • Then - Actions
          • Set F_AbillityCount = (F_AbillityCount + 1)
          • Set F_Caster = (Casting unit)
          • Set F_CasterPoint = (Position of F_Caster)
          • Unit - Create 1 Fire Fairy Dragon for (Owner of F_Caster) at (Position of F_Caster) facing (Position of F_Caster)
          • Set F_Fairy = (Last created unit)
          • Unit - Change color of F_Fairy to Blue
          • Special Effect - Create a special effect attached to the chest of F_Fairy using AttachedEffect
          • Special Effect - Create a special effect attached to the chest of F_Fairy using SummonEffect
          • Special Effect - Destroy (Last created special effect)
          • Set F_FairyFireCD = FireBoltCooldown
          • Trigger - Turn on Faerie Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation(udg_F_CasterPoint)
      • Custom script: call RemoveLocation(udg_F_FairyPoint)
  • Faerie Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (F_Caster is alive) Equal to True
        • Then - Actions
          • Set F_FairyFireCD = (F_FairyFireCD + 1)
          • Set F_BlinkCD = (F_BlinkCD + 1)
          • Set F_TickMove = (F_TickMove + 1)
          • Set F_FairyPoint = (Position of F_Fairy)
          • Set F_CasterPoint = (Position of F_Caster)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between F_FairyPoint and F_CasterPoint) Greater than or equal to DistanceBlink
              • F_BlinkCD Greater than or equal to 5
            • Then - Actions
              • Unit - Move F_Fairy instantly to F_CasterPoint, facing F_FairyPoint
              • Special Effect - Create a special effect attached to the chest of F_Fairy using BlinkEffect
              • Special Effect - Destroy (Last created special effect)
              • Set F_TickMove = 0
              • Set F_BlinkCD = 0
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • F_TickMove Greater than or equal to MoveFrequency
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between F_FairyPoint and F_CasterPoint) Greater than or equal to FollowRange
                    • Then - Actions
                      • Unit - Order F_Fairy to Right-Click F_Caster
                      • Set F_TickMove = 0
                    • Else - Actions
                      • Unit - Order F_Fairy to Move To (Random point in (Region centered at F_CasterPoint with size (MoveArea, MoveArea)))
                      • Set F_TickMove = 0
                • Else - Actions
        • Else - Actions
          • Unit - Kill F_Fairy
          • Trigger - Turn off (This trigger)
      • Custom script: call RemoveLocation(udg_F_CasterPoint)
      • Custom script: call RemoveLocation(udg_F_FairyPoint)
  • Faerie Bolt
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Attacking unit) Equal to F_Caster
    • Actions
      • Set F_FairyPoint = (Position of F_Fairy)
      • Set F_CasterPoint = (Position of F_Caster)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • F_FairyFireCD Greater than or equal to FireBoltCooldown
          • (Distance between F_FairyPoint and F_CasterPoint) Less than or equal to DistanceFairyFire
        • Then - Actions
          • Trigger - Turn off Faerie Loop <gen>
          • Set F_TickMove = 0
          • Set F_FairyFireCD = 0
          • Set F_AttackTarget = (Attacked unit)
          • Unit - Order F_Fairy to Neutral Alchemist - Acid Bomb F_AttackTarget
          • Trigger - Turn on Faerie Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation(udg_F_CasterPoint)
      • Custom script: call RemoveLocation(udg_F_FairyPoint)
 
Last edited:
From the looks of it, all you really have to do is learn the indexing method and switch most of your variables to arrays and add in the indexing method which is setting the start array/index plus one and looping it then once that instance/cast is done decrease the array/index by one. Might sound complex, but its super simple.

Stop using GUI

This isn't 2003-2009 anymore.
 
Level 2
Joined
Aug 9, 2016
Messages
9
Ok guys I've done what you said, but I'm stuck in this part.

  • Faerie Summon
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to F_SummonedUnit
    • Actions
      • Set F_Index = (F_Index + 1)
      • -------- -------- --------
      • Set F_Fairy[F_Index] = (Summoned unit)
      • Set F_Caster[F_Index] = (Summoning unit)
      • -------- -------- --------
      • Set F_CasterPoint[F_Index] = (Position of F_Caster[F_Index])
      • Set F_FairyPoint[F_Index] = (Position of F_Fairy[F_Index])
      • -------- -------- --------
      • Set F_CasterPointRemove = F_CasterPoint[F_Index]
      • Set F_FairyPointRemove = F_FairyPoint[F_Index]
      • -------- -------- --------
      • Trigger - Turn on Faerie Loop <gen>
      • -------- -------- --------
      • Custom script: call RemoveLocation(udg_F_FairyPointRemove)
      • Custom script: call RemoveLocation(udg_F_CasterPointRemove)
The problem here is how can I check if my caster have a active summon and how to decrese his index,
cuz every time I use this abillity a new index is created with units already in other instances.
All methods that I've tried bring me back to the same place. :(
But when the caster dies it will be decreased from index. Basically copying the tutorial KILLCIDE showed me.:D

Here is the general code.

  • Faerie Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • F_Index Greater than or equal to 1
        • Then - Actions
          • For each (Integer F_LoopAction) from 1 to F_Index, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (F_Caster[F_LoopAction] is alive) Equal to True
                • Then - Actions
                  • Set F_TickMove[F_LoopAction] = (F_TickMove[F_LoopAction] + 1)
                  • Set F_TickMoveCD[F_LoopAction] = (F_TickMoveCD[F_LoopAction] - 1)
                  • -------- -------- --------
                  • Set F_AbillityCD[F_LoopAction] = (F_AbillityCD[F_LoopAction] + 1)
                  • Set F_BlinkCD[F_LoopAction] = (F_BlinkCD[F_LoopAction] + 1)
                  • -------- -------- --------
                  • Set F_FairyPoint[F_LoopAction] = (Position of F_Fairy[F_LoopAction])
                  • Set F_CasterPoint[F_LoopAction] = (Position of F_Caster[F_LoopAction])
                  • -------- -------- --------
                  • Set F_CasterPointRemove = F_CasterPoint[F_LoopAction]
                  • Set F_FairyPointRemove = F_FairyPoint[F_LoopAction]
                  • -------- -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between F_CasterPointRemove and F_FairyPointRemove) Greater than or equal to Distance_Blink
                      • F_BlinkCD[F_LoopAction] Greater than or equal to 5
                    • Then - Actions
                      • Unit - Move F_Fairy[F_LoopAction] instantly to F_CasterPointRemove, facing F_CasterPointRemove
                      • -------- -------- --------
                      • Special Effect - Create a special effect attached to the chest of F_Fairy[F_LoopAction] using Blink_Effect
                      • Special Effect - Destroy (Last created special effect)
                      • -------- -------- --------
                      • Set F_BlinkCD[F_LoopAction] = 0
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • F_TickMove[F_LoopAction] Greater than or equal to Move_Frequency
                          • F_TickMoveCD[F_LoopAction] Less than or equal to 0
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Distance between F_CasterPointRemove and F_FairyPointRemove) Greater than or equal to Follow_Range
                            • Then - Actions
                              • Unit - Order F_Fairy[F_LoopAction] to Right-Click F_Caster[F_LoopAction]
                              • -------- -------- --------
                              • Set F_TickMove[F_LoopAction] = 0
                            • Else - Actions
                              • Unit - Order F_Fairy[F_LoopAction] to Move To (Random point in (Region centered at F_CasterPointRemove with size (Move_Area, Move_Area)))
                              • -------- -------- --------
                              • Set F_TickMove[F_LoopAction] = 0
                        • Else - Actions
                • Else - Actions
                  • Unit - Kill F_Fairy[F_LoopAction]
                  • -------- -------- --------
                  • Set F_Caster[F_LoopAction] = F_Caster[F_Index]
                  • Set F_Fairy[F_LoopAction] = F_Fairy[F_Index]
                  • -------- -------- --------
                  • Set F_FairyPoint[F_LoopAction] = (Position of F_Fairy[F_LoopAction])
                  • Set F_CasterPoint[F_LoopAction] = (Position of F_Caster[F_LoopAction])
                  • -------- -------- --------
                  • Set F_CasterPointRemove = F_CasterPoint[F_LoopAction]
                  • Set F_FairyPointRemove = F_FairyPoint[F_LoopAction]
                  • -------- -------- --------
                  • Set F_Index = (F_Index - 1)
                  • Set F_LoopAction = (F_LoopAction - 1)
                  • -------- -------- --------
                  • Set F_TickMove[F_LoopAction] = 0
                  • Set F_BlinkCD[F_LoopAction] = 0
        • Else - Actions
          • Trigger - Turn off (This trigger)
      • Custom script: call RemoveLocation(udg_F_FairyPointRemove)
      • Custom script: call RemoveLocation(udg_F_CasterPointRemove)
  • Faerie Abillity
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) Equal to F_SummoningUnit[1]
          • (Unit-type of (Attacking unit)) Equal to F_SummoningUnit[2]
          • (Unit-type of (Attacking unit)) Equal to F_SummoningUnit[3]
    • Actions
      • Set F_AbillityCaster = (Attacking unit)
      • For each (Integer F_LoopAbillity) from 1 to F_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • F_AbillityCaster Equal to F_Caster[F_LoopAbillity]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • F_AbillityCD[F_LoopAbillity] Greater than or equal to Abillity_Cooldown
                  • (Distance between F_CasterPointRemove and F_FairyPointRemove) Less than or equal to Distance_Abillity
                • Then - Actions
                  • Set F_AbillityTarget[F_LoopAbillity] = (Attacked unit)
                  • -------- -------- --------
                  • Set F_AbillityCD[F_LoopAbillity] = 0
                  • -------- -------- --------
                  • Set F_TickMoveCD[F_LoopAbillity] = Move_FrequencyCD
                  • -------- -------- --------
                  • Unit - Order F_Fairy[F_LoopAbillity] to Neutral Alchemist - Acid Bomb F_AbillityTarget[F_LoopAbillity]
                • Else - Actions
            • Else - Actions
Sorry for my leak of knowledge, never tried something like this, and as I said, I have no idea how to use JASS neither hashtables. Any help is welcome. :)
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
Didnt check through your code but if you want to learn MUI using hashtables and indexing easily you could check out my tutorial map attached on my signature, it is detailed for simplicity.
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
So your problem is if the unit already has a companion don't let them have another one?


Your problem is you're "deindexing improperly".

To deindex: You need to set all the variables for the current instance equal to the max instance and then lower the instance count.

Set F_TickMove[F_LoopAction] = 0
// These are just incorrect right here, but how you
Set F_BlinkCD[F_LoopAction] = 0 // were trying to set the other ones were close


Ex of how it will look:
Set F_TickMove[F_LoopAction] = F_TickMove[F_Index]
Set F_BlinkCD[F_LoopAction] = F_BlinkCD[F_Index]
Set All F_Caster/Fairy, everything that you initially assigned then de-increment as you did

Set F_Index = F_Index - 1
Set F_LoopAction = F_LoopAction - 1
 
Last edited:
Level 2
Joined
Aug 9, 2016
Messages
9
Yes, every time I cast the abillity it will add a new index, for example Unit 1 casts, then he receives index 1, but if a cast it again with the same unit he will receive index 2, so index 1 and index 2 are the same caster, and index 1 fairy count will be missing cuz fairy will be desummoned. I don't know to save a caster id to check if he has a "abillity count" or not.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
If you dont want the caster to be stack then you should use hashtable for it's handle or just create a unit group and integrate the caster into it then before indexing you must check if the caster is already in that particular group.
 
Level 2
Joined
Aug 9, 2016
Messages
9
OK thx guys for all of your replies, I apreciatte to see how this commuty is great! :D
It's done, its very simple but it's done. I'm not sure if I can upload this in Spell section. For now it suports your summoned unit to have only 1 abillity. I'm working on it right now, but in general it's done.
Even so thanks guys!

If You want to check/test it, here it is...
 

Attachments

  • fairy.w3x
    74.2 KB · Views: 30
Status
Not open for further replies.
Top