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

Spell-Caster behind the target

Status
Not open for further replies.
Hi!

I have this idea in my head, but i don't know how to set a condition.
It should go like this:
  • If (Facing of (Target unit of ability being cast)) Equal to ((Facing of (Triggering unit)) - (Random real number between 0.00 and 180.00))
I know its wrong, because it don't work D: (its just to see what i mean)

So if Triggering unit is behind the Target unit of ability being cast the actions should run, else not
(for exsample dota spell "backstab" from rikimaru, I only need a condition nothing else)

Thanks!

-BerZeKeR-
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Here:
  • ((Facing of (Target unit of ability being cast)) Greater than or equal to ((Facing of (Triggering unit)) - 180.00)) and ((Facing of (Target unit of ability being cast)) Less than or equal to ((Facing of (Triggering unit)) + 180.00))
This checks if the target is behind you.

  • ((Facing of (Triggering Unit)) Greater than or equal to ((Facing of (Target unit of ability being cast)) - 180.00)) and ((Facing of (Triggering Unit)) Less than or equal to ((Facing of (Target unit of ability being cast)) + 180.00))
This checks if the you are behind your target.
 
Last edited:
Level 21
Joined
Aug 9, 2006
Messages
2,384
Thats wrong, you can do it better, but you need 2 angles for it, so lets think, if the units facing is 270 degrees then + 180 is directly behind him, now if you check that the facing angle between the target and the caster is greater as (facing angle of caster +135) and smaller as (facing angle of caster + 225) degrees is just the 45 degrees behind the target possible, that would make it not so hard to hit the back but wont make it odd looking.
 
So how should i actually set it?
with two conditions +/-?

Edit:
I have another problem with windwalk +damage text becuse im using this and it dispays "0! and 380!" and it looks stupid...

  • Stealth
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) has buff Stealth ) Equal to True
    • Actions
      • Set TempLoc16 = (Position of (Attacked unit))
      • Wait 0.10 game-time seconds
      • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (10.00 x (Real((Agility of (Attacking unit) (Include bonuses))))) damage of attack type Spells and damage type Normal
      • Special Effect - Create a special effect attached to the chest of (Attacked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • Floating Text - Destroy (Last created floating text)
      • Floating Text - Create floating text that reads ((String(((Integer((Real((Agility of (Attacking unit) (Include bonuses)))))) x 10))) + !) at TempLoc16 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
      • Floating Text - Show (Last created floating text) for (All players)
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
      • Wait 2.00 game-time seconds
      • Floating Text - Destroy (Last created floating text)
      • Custom script: call RemoveLocation(udg_TempLoc16)
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
Lol.
Checking facing angles :D
Check the facing angle and the angle between the positions of the two units.
SO you either do that in the actions, instead of doing so in the conditions(because of leaks).
P.s. If you do it in jass, that you can do it in the conditions
 
Lol.
Checking facing angles :D
Check the facing angle and the angle between the positions of the two units.
SO you either do that in the actions, instead of doing so in the conditions(because of leaks).
P.s. If you do it in jass, that you can do it in the conditions

Any specific action condition i can use?(not in Jass)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Set temp_point1= location of Triggering unit.
Set temp_point2= location of Attacking unit
Set a = angle between temp_point1 and temp_point2 (unnecessary line)
Set b = Facing angle of (triggering unit) (unnecessary line)
If ( b > Modulo(a +90,360) OR b<Modulo(a-90,360) )
I just wrote that, so it is neither jass nor GUI but I think you will get the idea.

Edited! Thanks to HINDYhat for the reminder.
P.s. I guess negative angles should be taken care of aswell.
 
Last edited:
Now i made this, i didn't test it jet, I hope it works!

  • ((Facing of (Attacking unit)) Greater ((Angle from TempLoc17 to TempLoc16) + (90.00 mod 360.00))) or ((Facing of (Attacking unit)) Less than ((Angle from TempLoc17 to TempLoc16) - (90.00 mod 360.00)))
Damn it still doesn't work right
  • Stealth
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) has buff Stealth ) Equal to True
    • Actions
      • Set TempLoc17 = (Position of (Attacking unit))
      • Set TempLoc16 = (Position of (Attacked unit))
      • Set AngleVar = (Integer((Angle from TempLoc17 to TempLoc16)))
      • Set AngleVar01 = (Integer((Facing of (Attacking unit))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Facing of (Attacking unit)) Greater than ((Angle from TempLoc17 to TempLoc16) + (90.00 mod 360.00))) or ((Facing of (Attacking unit)) Less than ((Angle from TempLoc17 to TempLoc16) - (90.00 mod 360.00)))
        • Then - Actions
          • Animation - Play (Attacking unit)'s slam animation
          • Set TempLoc16 = (Position of (Attacked unit))
          • Unit - Remove Stealth buff from (Attacking unit)
          • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (10.00 x (Real((Agility of (Attacking unit) (Include bonuses))))) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the chest of (Attacked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Floating Text - Create floating text that reads ((String(((Integer((Real((Agility of (Attacking unit) (Include bonuses)))))) x 10))) + !) at TempLoc16 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Show (Last created floating text) for (All players)
          • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
          • Custom script: call RemoveLocation(udg_TempLoc16)
          • Wait 1.50 game-time seconds
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
and jeah some variables are useles, I couldn't use them in condition
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
:)
If ( b > Modulo(a +90,360) OR b<Modulo(a-90,360) )
You placed the mod at the wrong place.
You couldn't use the variables because they should be reals, not integers(temp_real).
" Animation - Play (Attacking unit)'s slam animation
Set TempLoc16 = (Position of (Attacked unit)) "
Last line unnecessary(maybe even causes a leak).
You also need to remove temploc17.
You can use triggering unit instead of attacking unit.
P.s. I wonder why you need seventeen templocs.
 
Last edited:
I'm making a spell pack(in my signature, this is about 10/11 spell)

Edit: now it doesn't work at all :S

  • Set TempLoc16 = (Position of (Attacking unit))
  • Set TempLoc17 = (Position of (Attacked unit))
  • Set AngleVar = (Angle from TempLoc16 to TempLoc17)
  • Set AngleVar01 = (Facing of (Attacking unit))
  • ---------------------------------------------------
  • (AngleVar01 Greater than (AngleVar + (90.00 mod 360.00))) or (AngleVar01 Less than (AngleVar - (90.00 mod 360.00)))
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
(AngleVar01 Greater than ((AngleVar + 90.00) mod 360.00)) or (AngleVar01 Less than ((AngleVar - 90.00) mod 360.00))

But as I said, (AngleVar - 90.00) can be negative. And AngleVar01 is always > 0.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Figures.
Set AngleVar = (Integer((Angle from TempLoc17 to TempLoc16)))
Should be:
Set AngleVar = (Integer((Angle from TempLoc16 to TempLoc17)))
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
First Jass function I've ever made. Seriously, this was the FIRST working function I had written. Curious coincidence this is exactly what you need. :p

Returns a boolean, to see if a unit (Who) is behind another unit (BehindWho).

Use the Angle variable in the function calling for a "more or less" value. Never set this value to 0.0, the function will almost never return true... The function will check if a unit is facing in the same direction as another one, more or less the Angle value.

JASS:
function IsUnitBehind takes unit Who, unit BehindWho, real Angle returns boolean
    local real d=GetUnitFacing(Who)-GetUnitFacing(BehindWho)
    if d>=180.0 then
        set d=d-360
    elseif d<=-180.0 then
        set d=d+360
    endif
    return (d<=Angle and d>=-Angle)
endfunction
 
@Eccho, I'll try your trigger out
@spiwn, it still doesn't work
@HINDYhat, I don't know anything about Jass

Edit:
@Eccho,
  • Stealth Copy
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) has buff Stealth ) Equal to True
    • Actions
      • Set AngleVar01 = (Facing of (Attacking unit))
      • Set TempLoc16 = (Position of (Attacking unit))
      • Set TempLoc17 = (Position of (Attacked unit))
      • Set AngleVar = (Angle from TempLoc16 to TempLoc17)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AngleVar Less than 0.00
        • Then - Actions
          • Set AngleVar = (360.00 + AngleVar)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AngleVar Less than ((Facing of (Attacking unit)) + 45.00)
          • AngleVar Greater than ((Facing of (Attacking unit)) - 45.00)
        • Then - Actions
          • Animation - Play (Attacking unit)'s slam animation
          • Unit - Remove Stealth buff from (Attacking unit)
          • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (10.00 x (Real((Agility of (Attacking unit) (Include bonuses))))) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the chest of (Attacked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Floating Text - Create floating text that reads ((String(((Integer((Real((Agility of (Attacking unit) (Include bonuses)))))) x 10))) + !) at TempLoc16 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Show (Last created floating text) for (All players)
          • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
          • Wait 1.50 game-time seconds
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TempLoc17)
      • Custom script: call RemoveLocation(udg_TempLoc16)
Doesn't work right :( even if i use unit group...
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
well no, since the angle is not right I assume. What is happening if you change
AngleVar Less than ((Facing of (Attacking unit)) + 45.00)
to
AngleVar Less than ((Facing of (Attacking unit)) + 90.00) and respictively
AngleVar Less than ((Facing of (Attacking unit)) - 90.00)?

Also, maybe its the floating text? Try a game message.

If I get it right? You want a "backstab" attack if the unit breaks the stealth?
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Dunno if this works. I guess it should:

  • Stealth
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) has buff Stealth ) Equal to True
    • Actions
      • Set Real = ((Facing of (Attacking unit)) - (Facing of (Attacked unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Real Greater than or equal to 180.00
        • Then - Actions
          • Set Real = (Real - 360.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Real Less than or equal to -180.00
            • Then - Actions
              • Set Real = (Real + 360.00)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Real Less than or equal to 45.00
          • Real Greater than or equal to -45.00
        • Then - Actions
          • -------- SUCCESFUL BACKDOOR PWN CODE GOES HERE! --------
        • Else - Actions
 
  • Stealth Copy Copy
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) has buff Stealth ) Equal to True
    • Actions
      • Set AngleVar = ((Facing of (Attacking unit)) - (Facing of (Attacked unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AngleVar Greater than or equal to 180.00
        • Then - Actions
          • Set AngleVar = (AngleVar - 360.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AngleVar Less than or equal to -180.00
            • Then - Actions
              • Set AngleVar = (AngleVar + 360.00)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AngleVar Less than or equal to 45.00
          • AngleVar Greater than or equal to -45.00
        • Then - Actions
          • Animation - Play (Attacking unit)'s slam animation
          • Unit - Remove Stealth buff from (Attacking unit)
          • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (10.00 x (Real((Agility of (Attacking unit) (Include bonuses))))) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the chest of (Attacked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Floating Text - Create floating text that reads ((String((Real(((Agility of (Attacking unit) (Include bonuses)) x 10))))) + !) above (Attacked unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Show (Last created floating text) for (All players)
          • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
          • Wait 1.50 game-time seconds
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
Its still don't work
Now i'll go kill myself, this spell is evil.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
@HINDYhat
Using only unit facings ...
So you make sure, the both units are facing almost the same way, but you do not check which unit is behind which one.
 
Thanks HINDY! works great!!
  • Stealth Copy Copy
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) has buff Stealth ) Equal to True
    • Actions
      • Set AngleVar = ((Facing of (Attacking unit)) - (Facing of (Attacked unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AngleVar Greater than or equal to 180.00
        • Then - Actions
          • Set AngleVar = (AngleVar - 360.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AngleVar Less than or equal to -180.00
            • Then - Actions
              • Set AngleVar = (AngleVar + 360.00)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AngleVar Less than or equal to 45.00
          • AngleVar Greater than or equal to -45.00
        • Then - Actions
          • Animation - Play (Attacking unit)'s slam animation
          • Unit - Remove Stealth buff from (Attacking unit)
          • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (10.00 x (Real((Agility of (Attacking unit) (Include bonuses))))) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the chest of (Attacked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Floating Text - Create floating text that reads ((String((Real(((Agility of (Attacking unit) (Include bonuses)) x 10))))) + !) above (Attacked unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Show (Last created floating text) for (All players)
          • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
          • Wait 1.50 game-time seconds
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
 
I have another problem is there a condition/action anything that would sound like
"Matching unit is currently attacked by triggering unit"?
Its for my new spell where hero is attacking unit, than it cast(taunt(no target spell)), than it search for the unit in unit group that is "Matching unit is currently attacked by triggering unit"
I just ask if its anything like that, or custom script, just let me know if it is (and tell me where) other i'll manage myself.
THX!

-BerZeKeR-
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
I think it has to be done with jass. It depends on how many who can have it at once though. But no that "pre" specific script does not exist

The idea would be I think, in MPI (player arrays)

  • AttackSimulation
  • Events
    • Unit - Unit is attacked
  • Conditions
    • Unit-type of attacking unit is equal to "your choice"
  • Actions
    • Set CurrentTarget[Player number of owner of attacking unit] = Triggering unit
And then

  • TauntEffect
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • Ability being cast is equal to "TauntChoice"
  • Actions
    • //This part is only used if you want to check if the last target is within a specific range of the caster
    • Set TempPointA = Position of Triggering Unit
    • Set TempPointB = Position of CurrentTarget[Player number of owner of triggering unit]
    • // ---
    • If actions - CurrentTarget[Player number of owner of triggering unit] is alive equal to true and distance between TempPointA and TempPointB is less than or equal to 400 (as example) then - actions
      • //Do Actions regarding last attacked unit of triggering unit, example
      • Unit - Issue triggering unit to attack CurrentTarget[Player number of owner of triggering unit]
    • else - actions
  • Custom script - call RemoveLocation( udg_TempPointA )
  • Custom script - call RemoveLocation( udg_TempPointB )
Hm well, Im sorry for the incorrect trigger tagging, I do not have we at the moment.
hope you understood the whole idea.
 
Status
Not open for further replies.
Top