| 03-21-2007, 05:12 AM | #1 | ||
What A "Backstab" Is There appears to be a desire with people these days to make spells and/or systems based off of "backstabbing". Essentially, a backstab is a check that goes off when a unit is attacked which compares each unit's facings to see if it is within a specific angle. The Procedure In order to get our backstab working, we must understand the general steps behind doing so. I will be doing this as though I am detecting when a unit with some passive backstab ability attacks, and will do 50*Level damage and display a text message. The procedure:
What You'll Need We will be using a JASS function to get the angle difference (it is possible in GUI alone; see bottom of tutorial), thus we will need this function. Here is the function by Vexorian, with a description of each line by Ammorth: Quote:
Trigger: Setting Up The Check The first thing to do is import the JASS code into the map. Put it in the "custom script" section of the map header (click on the thing where it says "Your Map Name (Whatever it is).w3x" in the trigger editor). It should look like this: Next, we'll need to set up the angle checking part of our trigger, we'll do this by using the local variable GUI bug, as discussed in "Method 3" in this tutorial. Then, we'll call our new JASS script, and set the variable equal to that, by adding these lines to the top of the trigger: Trigger: ![]() Custom script: local real udg_Backstab_Angle ![]() Custom script: set udg_Backstab_Angle = Backstab_GetAngleDifference(GetUnitFacing(GetTriggerUnit()), GetUnitFacing(GetAttacker()))Last, we'll need an If/Then/Else that compares "Backstab_Angle" to the allowed angle range and executes our actions if it's within the range. Let's say our range is 60*. It should look like this: Trigger: If (All Conditions are true) then do (Then actions) else do (Else actions)![]() Then - Actions![]() ![]() Unit - Cause (Attacking unit) to damage (Triggering unit) dealing (50 * (Level of (Backstab Test Ability) for (Attacking Unit))) damage of attack type Normal and damage type Universal![]() ![]() Floating Text - Create floating text that reads |cff6600Backstab!|r above (Attacking Unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency![]() ![]() Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees![]() ![]() Floating Text - Change (Last created floating text): Disable permenance![]() ![]() Floating Text - Set the lifespan of (Last created floating text) to 2.25 seconds![]() Else - ActionsPutting It Together All put together, the whole trigger would look like this: Trigger: Backstab Test![]() Actions![]() ![]() Custom script: local real udg_Backstab_Angle ![]() ![]() Custom script: set udg_Backstab_Angle = Backstab_GetAngleDifference(GetUnitFacing(GetTriggerUnit()), GetUnitFacing(GetAttacker()))![]() ![]() If (All Conditions are true) then do (Then actions) else do (Else actions)![]() ![]() ![]() Then - Actions![]() ![]() ![]() ![]() Unit - Cause (Attacking unit) to damage (Triggering unit) dealing (50 * (Level of (Backstab Test Ability) for (Attacking Unit))) damage of attack type Normal and damage type Universal![]() ![]() ![]() ![]() Floating Text - Create floating text that reads |cff6600Backstab!|r above (Attacking Unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency![]() ![]() ![]() ![]() Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees![]() ![]() ![]() ![]() Floating Text - Change (Last created floating text): Disable permenance![]() ![]() ![]() ![]() Floating Text - Set the lifespan of (Last created floating text) to 2.25 seconds![]() ![]() ![]() Else - Actions
And there you have it! A simple, passive backstab spell! This same method can be used, for instance, to deal extra damage when a unit uses a spell, etc. Coming next:
Thanks to emjl3r for informing me of the lines I forgot. |
| 03-21-2007, 06:26 AM | #2 |
Seems like this topic would be more suited as a sample due to how specific it is. But, the tutorial is written fairly well so I think it's fine. However, I might suggest attaching a map using the back-stab as an example as well. +Rep for the nice (even if it seems a bit too specific) tutorial. EDIT: Post number 333! |
| 03-21-2007, 10:18 AM | #3 |
broken links make a demo for this -Av3n |
| 03-21-2007, 04:59 PM | #4 |
in your put it all togther, you left out that part that actually sets the real's value in the first place, and why use a local real? I don't see the need to do that |
| 03-21-2007, 07:30 PM | #5 |
emjlr3, I'm using a local real just because it makes the code more sound (it would be fine to do it without the local, though), and thanks for letting me know I forgot a few lines! ![]() Off-topic: How much rep do I have? I thought I had 175ish, but I no longer have a blue gem, and it says I have 131. I am on a school computer, so it could just be retarded. |
| 03-23-2007, 04:20 AM | #6 |
Allrighty, I fixed those pictures and re-wrote the code in GUI for those who cannot comprehend JASS scripts. Aside from a demo map, what else should I have to get this approved? |
| 04-28-2007, 08:31 AM | #7 |
A demo map will be more than sufficient. Well done! I'll approve this, but if you can, a demo would still be nice. |
| 04-28-2007, 06:05 PM | #8 |
I managed to get the "backstab" effect working with much simpler triggers. I wonder why mine worked if it needs to be this complex... |
| 04-29-2007, 10:27 PM | #9 |
Well, Dark.Revenant, what did you do? Oh, and this is a bit buggy. If you spam the attack button when behind some unit, you can deal bonus damage without actually attacking. The smart thing to do would be to use JASS and Dynamic triggers to detect the actual damage. Maybe I'll do that tutorial sometime. Demo map on the way. |
| 04-30-2007, 06:34 AM | #10 |
ya pyro, wtf, why dont you just use Trigger: ((Attacking unit) is behind (Attacked unit) Equal to True/sarcasm off |
| 04-30-2007, 05:08 PM | #11 | |
Quote:
Really, Dark.Revenant, what did you do? |
| 05-02-2007, 02:10 AM | #12 |
It was roughly 20 GUI lines total. It works perfectly. Unfortunately, it is map specific and is used to calculate rear hits and side hits from tank shells in Tank Blitz II. Trigger: If (All Conditions are True) then do (Then Actions) else do (Else Actions)
|
| 08-28-2007, 01:16 AM | #14 |
Glad to see you contributed to this thread. |
| 09-12-2007, 06:36 PM | #15 |
Nice, but I really hate JASS and custom script, EVERY TIME that I attemp to do something with them theres a error!Graaaah this is driving me crazy! Why this isn't working? set udg_Backstab_Angle = Backstab_GetAngleDifference(GetUnitFacing(GetAttackedUnit()), GetUnitFacing(GetAttacker())) |
