• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Please help me with this script :(

Status
Not open for further replies.

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
This isnt MUI
Trigger
  • Holy Flash Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Flash
    • Actions
      • Set HFCaster = (Casting unit)
      • Set HFPlayer = (Owner of HFCaster)
      • Set HFTargetPoint = (Target point of ability being cast)
      • Set HFLevel = (Level of (Ability being cast) for HFCaster)
      • Unit - Create 1 Holy Flash Stun for HFPlayer at HFTargetPoint facing (Random angle) degrees
      • Set HFDummy = (Last created unit)
      • Unit - Set level of Stun (Holy Flash) for HFDummy to HFLevel
      • Set HFGroup = (Units within (200.00 + (100.00 x (Real(HFLevel)))) of HFTargetPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of HFPlayer) Equal to True))))
      • Trigger - Turn on Holy Flash Loop <gen>
  • Holy Flash Loop
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set HFStunTarget = (Random unit from HFGroup)
      • Set HFTargetLoc = (Position of HFStunTarget)
      • Set HFTargetFacingAngle = (Facing of HFStunTarget)
      • Set HFTargetAngle = (Angle from HFTargetLoc to HFTargetPoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (HFTargetFacingAngle + 90.00) Less than or equal to ((HFTargetAngle + 90.00) + 90.00)
              • (HFTargetFacingAngle + 90.00) Greater than or equal to ((HFTargetAngle + 90.00) - 90.00)
        • Then - Actions
          • Unit - Order HFDummy to Human Mountain King - Storm Bolt HFStunTarget
        • Else - Actions
      • Unit Group - Remove HFStunTarget from HFGroup
      • Custom script: call RemoveLocation(udg_HFTargetLoc)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in HFGroup) Equal to 0
        • Then - Actions
          • Unit - Remove HFDummy from the game
          • Custom script: call RemoveLocation(udg_HFTargetPoint)
          • Custom script: call DestroyGroup(udg_HFGroup)
          • Trigger - Turn off (This trigger)
        • Else - Actions
I wanna create a spell named flashbang, so that the unit that face to the light will be stunned. But I have a problem, the stun only works for units that face north or between 0-180 degrees. doesn't work to units that face south or between 180-360 degrees. I dont know what's wrong. Please help :vw_death:


then...

All units within the red line get stunned, but why doesn't it work to the units within green line? :( please help
 
Last edited by a moderator:
Level 13
Joined
Jan 30, 2012
Messages
1,298
yes, it's isn't MUI
i don't know what your choice "MUI" or not
don't use Casting Unit
and

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
        • Conditions
but
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
 
Level 29
Joined
Sep 26, 2009
Messages
2,595
It won't get stunned because of the angle calculation.
When you take "facing unit" or unit's angle, those angles range from 0° to 360°, however the action "angle between points" calculates angles as [-180° <- 0° -> 180°] (basically, unit's angle 225° is shown as -135° if calculated via action "angle between points")

Also, why don't you pick every unit immediately? Why pick 1 target every 0,01 second?
 
Level 29
Joined
Sep 26, 2009
Messages
2,595
Also note, that the spell would still not fire properly for some units that are to the left of the flashbang, because you don't compare angles themselves, but real number (which are equal to angle).
That means that if:
- HFTargetFacingAngle is 340°
- HFTargetAngle is 25°

and you use this:
a) (HFTargetFacingAngle + 90.00) Less than or equal to ((HFTargetAngle + 90.00) + 90.00)
b) (HFTargetFacingAngle + 90.00) Greater than or equal to ((HFTargetAngle + 90.00) - 90.00)

then you end up comparing numbers
Then you calculate and compare, you will compare numbers:
a) 430 Less than or equal to 205
b) 430 Greater than or equal to 25

Since you use "and" condition and one of these conditions is not true, it will return false, so your unit won't get stunned.

Notice - you compare real number, although those number are taken from angles, they won't be calculated as such, so 430 is number 430, it won't become 70

--------
Edit: that angle is abuot -30°, warstomp is not good idea, because it would stun also units which do not face the spell
 
Level 29
Joined
Sep 26, 2009
Messages
2,595
You shouldn't compare if unit faces the spell directly (because that will most likely never happen), but if it has the flashbang in its field of view. What the range for that field of view should be is your choice.

340° and 25° is in WC3 a 45° difference, because in angles, 360°= 0°
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
yeah, i know. so that i make the range
so i make it like:
lesser than [(HFTargetAngle+360)+60]
greater than [(HFTargetAngle+360)-60]

I have fix that so it won't results negative value :D
Edit: and I make that range smaller

AH this rocks my head :( Can you help me make the correct one? I don't have times just to fix one spell :(

Yay finally i found the proble :ogre_love:
Still looking for the solution :ogre_hurrhurr:
 
Last edited by a moderator:
Level 29
Joined
Sep 26, 2009
Messages
2,595
I think there was actually a good equation in some thread using acos(cos) for checking if units face each other, Maker could know what I talk about.

I'll try to search for it if I find it, but no promises here.

Edit:
You could try this:
  • How to make Conelike abilities
    • Events
    • Conditions
    • Actions
      • -------- --------------------------------- --------
      • -------- -- Set unit variables -- --------
      • -------- --------------------------------- --------
      • Set u1 = The possible target for stun
      • Set u2 = The flashbang
      • -------- --------------------------------- --------
      • -------- - Set point variables - --------
      • -------- --------------------------------- --------
      • Set p1 = (Position of u1) // position of the target
      • Set p2 = (Position of u2) // position of the Flashbang
      • -------- --------------------------------- --------
      • Set ang = (Facing of u1) // target's facing angle
      • -------- --------------------------------- --------
      • -------- --------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Acos((Cos((ang - (Angle from p1 to p2)))))) Less than or equal to 45.00 // this is 45° per side, so it is a 90° cone; 30° per side makes 60° cone
        • Then - Actions
          • -------- FACES FLASHBANG --------
        • Else - Actions
          • -------- DOES NOT FACE FLASHBANG --------
      • -------- --------------------------------- --------
      • -------- ------ Clear Leaks ------ --------
      • -------- --------------------------------- --------
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
      • Custom script: set udg_p1 = null
      • Custom script: set udg_p2 = null
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
Now my flashbang works properly :D
  • Holy Flash Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Flash
    • Actions
      • Set HFCaster = (Casting unit)
      • Set HFPlayer = (Owner of HFCaster)
      • Set HFTargetPoint = (Target point of ability being cast)
      • Set HFLevel = (Level of (Ability being cast) for HFCaster)
      • Unit - Create 1 Holy Flash Stun for HFPlayer at HFTargetPoint facing (Random angle) degrees
      • Set HFDummy = (Last created unit)
      • Unit - Add a 0.75 second Generic expiration timer to HFDummy
      • Unit - Set level of Stun (Holy Flash) for HFDummy to HFLevel
      • Set HFGroup = (Units within (200.00 + (100.00 x (Real(HFLevel)))) of HFTargetPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of HFPlayer) Equal to True))))
      • Set HFTotal = (Number of units in HFGroup)
      • Trigger - Run Holy Flash Loop <gen> (checking conditions)
  • Holy Flash Loop
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to HFTotal, do (Actions)
        • Loop - Actions
          • Set HFStunTarget = (Random unit from HFGroup)
          • Set HFTargetLoc = (Position of HFStunTarget)
          • Set HFTargetFacingAngle = (Facing of HFStunTarget)
          • Set HFTargetAngle = (Angle from HFTargetLoc to HFTargetPoint)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HFTargetFacingAngle Greater than or equal to 0.00
              • HFTargetFacingAngle Less than or equal to 180.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (HFTargetFacingAngle + 360.00) Less than or equal to ((HFTargetAngle + 360.00) + 60.00)
                  • (HFTargetFacingAngle + 360.00) Greater than or equal to ((HFTargetAngle + 360.00) - 60.00)
                • Then - Actions
                  • Unit - Order HFDummy to Human Mountain King - Storm Bolt HFStunTarget
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HFTargetFacingAngle Greater than or equal to 181.00
              • HFTargetFacingAngle Less than or equal to 360.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((180.00 - (HFTargetFacingAngle - 180.00)) + 360.00) Less than or equal to (((HFTargetAngle x -1.00) + 360.00) + 60.00)
                  • ((180.00 - (HFTargetFacingAngle - 180.00)) + 360.00) Greater than or equal to (((HFTargetAngle x -1.00) + 360.00) - 60.00)
                • Then - Actions
                  • Unit - Order HFDummy to Human Mountain King - Storm Bolt HFStunTarget
                • Else - Actions
            • Else - Actions
          • Unit Group - Remove HFStunTarget from HFGroup
          • Custom script: call RemoveLocation(udg_HFTargetLoc)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in HFGroup) Equal to 0
            • Then - Actions
              • Custom script: call RemoveLocation(udg_HFTargetPoint)
              • Custom script: call DestroyGroup(udg_HFGroup)
            • Else - Actions
I change periodic time method into integer loop bcz it works faster
:goblin_yeah::goblin_yeah::goblin_yeah:

Thnks dude for helping me...
 
Status
Not open for further replies.
Top