• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to exactly make % to cast a spell?

Status
Not open for further replies.
Level 2
Joined
Feb 19, 2023
Messages
4
I looked up the other posts and did the similar thing but seems not working (I'm just starting)
Wanted to make an aura that will have 50% chance to charm the attacking unit for the attacked unit

  • Aura of Persuasion
    • Events
      • Unit - A unit is Attacked
    • Conditions
      • (((Attacked unit) has buff Aura of Persuasion ) Equal to True) and ((Level of Aura of Persuasion for (Attacked unit)) Equal to 1)
    • Actions
      • Set Aura_i = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Aura_i Lesser than or Equal to 50
        • Then - Actions
          • Set Temppoint = (Position of (Attacked unit))
          • Unit - Create 1 Dummy for (Owner of (Attacked unit)) at Temppoint facing generic building facing degrees
          • Custom script: call RemoveLocation(udg_Temppoint)
          • Unit - Add Possession dummy Level 3 to (Last created unit)
          • Unit - Add a 1.00 second generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Undead - Banshee: Possession (Attacking unit)
          • Unit - Remove Possession dummy Level 3 from (Last created unit)
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,749
Why are you checking for both a Buff and the Level of the ability? If the Unit has the Buff then it either has the Ability or is under the effects of it. Also, why are you Removing the Possession ability from the Dummy? It won't be able to cast an ability it no longer has.

This should work fine assuming you've setup your Dummy unit correctly:
  • Aura of Persuasion
    • Events
      • Unit - A unit is Attacked
    • Conditions
      • ((Attacked unit) has buff Aura of Persuasion) Equal to True
    • Actions
      • Set Aura_i = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Lesser than or Equal to 50
        • Then - Actions
          • Set Temppoint = (Position of (Attacked unit))
          • Unit - Create 1 Dummy for (Owner of (Attacked unit)) at Temppoint facing generic building facing degrees
          • Custom script: call RemoveLocation(udg_Temppoint)
          • Set TempDummy = (Last created unit)
          • Unit - Add Possession dummy Level 3 to TempDummy
          • Unit - Add a 0.20 second generic expiration timer to TempDummy
          • Unit - Order TempDummy to Undead - Banshee: Possession (Attacking unit)
        • Else - Actions
The Dummy should be based on the Locust unit with Movement Type = None, Speed Base = 0, and Attacks Enabled = None.
 
Level 26
Joined
Sep 26, 2009
Messages
2,428
I would not add expiration timer to the dummy at all - the Possession spell destroys the caster while taking control of the target, anyway.

Edit: if the Possession spell is not used for the visuals (i.e. for the ghost banshee flying to the target), then you can directly change the owner of the attacking unit via triggers
 
Level 2
Joined
Feb 19, 2023
Messages
4
I change it to "change the owner" instead of casting the banshee spell as Nichilus suggested, makes it easier and no need to use the dummy.

Why are you checking for both a Buff and the Level of the ability? If the Unit has the Buff then it either has the Ability or is under the effects of it. Also, why are you Removing the Possession ability from the Dummy? It won't be able to cast an ability it no longer has.
My low iq brain don't know how to make it that on 1 level of the aura it will only take units equal or lesser than level 3, on aura level 2 - lesser or equal to level 5 etc etc, so i made 3 banshee spells, thats why i remove the spell from dummy so it won't break if second banshee spell gets added
 
Last edited:

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,749
I assumed you were using the Charm ability as that wouldn't have any weird issues.

Anyway, those abilities check for Unit Level when determining valid targets. If you wanted to do the same then you would Add conditions for that:
  • Aura of Persuasion
    • Events
      • Unit - A unit is Attacked
    • Conditions
      • ((Attacked unit) has buff Aura of Persuasion) Equal to True
      • (Random integer number between 1 and 100) Lesser than or Equal to 50
      • (Level of (Attacking unit) Less than or Equal to 3
      • (Attacking unit is a Hero) Equal to False
      • (Attacking unit is a Structure) Equal to False
    • Actions
      • Unit - Change ownership of (Attacking unit) to (Owner of (Attacked unit)) and Change color
You probably also want to exclude Heroes and Structures since those are generally unwanted targets for this effect.

Unfortunately, you can't get the Aura level through the Buff (that would be too easy and Blizzard hates easy), so you'll need to make multiple Buffs, one for each level. Then you can check for this specific Buff to determine the Ability level. Note that this will mean that your Unit can be affected by all three Buffs at once if they are in range of multiple Aura sources with differing Aura levels. The solution could be something like this:
  • Aura of Persuasion
    • Events
      • Unit - A unit is Attacked
    • Conditions
      • (Attacking unit is a Hero) Equal to False
      • (Attacking unit is a Structure) Equal to False
      • (Random integer number between 1 and 100) Lesser than or Equal to 50
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) has buff Aura of Persuasion Lvl 3) Equal to True
          • (Level of (Attacking unit) Less than or equal to 7
        • Then - Actions
          • Unit - Change ownership of (Attacking unit) to (Owner of (Attacked unit)) and Change color
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) has buff Aura of Persuasion Lvl 2) Equal to True
          • (Level of (Attacking unit) Less than or equal to 5
        • Then - Actions
          • Unit - Change ownership of (Attacking unit) to (Owner of (Attacked unit)) and Change color
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) has buff Aura of Persuasion Lvl 1) Equal to True
          • (Level of (Attacking unit) Less than or equal to 3
        • Then - Actions
          • Unit - Change ownership of (Attacking unit) to (Owner of (Attacked unit)) and Change color
        • Else - Actions
This will only Charm non-Hero, non-Structure units with a Level <= 3/5/7. Each level of Aura of Persuasion needs it's own unique buff.
 
Status
Not open for further replies.
Top