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

[REQUEST] Adv Dodge and Knockback

Status
Not open for further replies.
Level 3
Joined
Jan 10, 2010
Messages
29
Ok,
These are two 'systems' required for a Map that I am working on. They must be Leakless, MUI and NOT IN VJASS.

1: Adv Dodge
When a unit is attacked it has a chance (defined by a variable) to avoid all damage and move around to close to behind the attacking unit (Defined by the same variable). So if my 'dodge rating' is 100 then I have a 100% chance to dodge attacks and to move all the way around behind the enemy unit.

N.B. I cannot have instantly move to, I need the unit to 'slide' around the attacking unit.


2: Knock back
This is a two part system. Firstly It detects, that when a unit is attacked, and takes damage from the attack, the unit is then pushed back a distance defined by a variable. While the unit is being pushed back, and for 1.5 seconds after, the unit's damage is reduced by 50% and its armour is reduced to 0.

Any help would be appreciated. I Code in C++ and find the nuances of other languages strange.
 
Ok,
These are two 'systems' required for a Map that I am working on. They must be Leakless, MUI and NOT IN VJASS.

1: Adv Dodge
When a unit is attacked it has a chance (defined by a variable) to avoid all damage and move around to close to behind the attacking unit (Defined by the same variable). So if my 'dodge rating' is 100 then I have a 100% chance to dodge attacks and to move all the way around behind the enemy unit.

N.B. I cannot have instantly move to, I need the unit to 'slide' around the attacking unit.


2: Knock back
This is a two part system. Firstly It detects, that when a unit is attacked, and takes damage from the attack, the unit is then pushed back a distance defined by a variable. While the unit is being pushed back, and for 1.5 seconds after, the unit's damage is reduced by 50% and its armour is reduced to 0.

Any help would be appreciated. I Code in C++ and find the nuances of other languages strange.

the knockback is easy, also the damage reduction after and the 0 armor, I'm sure you can set devotion aura's effect to be a percentage of the base armor so use a -1 and turn percentage to on, but it only reduces "base" armor if I'm right so any increase in armor after the base isn't calculated by the skill anymore, so if your units can increase in armor then you will need more code for it... You can search for knockbacks in the spell section and I can say that you can easily edit an existing system since you can code in
C++...
 
Level 3
Joined
Jan 10, 2010
Messages
29
I cant code in vJass because I cannot get Jass Newgen, not because Im a shoddy coder. Thank you Adiktuz for actually answering my question.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
HaPpY sAdIsT, I like your rotating 4-dimensional cube. That looks so trippy.

HaPpY sAdIsT said:
1: Adv Dodge
When a unit is attacked it has a chance (defined by a variable) to avoid all damage and move around to close to behind the attacking unit (Defined by the same variable). So if my 'dodge rating' is 100 then I have a 100% chance to dodge attacks and to move all the way around behind the enemy unit.

N.B. I cannot have instantly move to, I need the unit to 'slide' around the attacking unit.

Okay to avoid the damage dealt isn't a problem, unless it is lethal damage, in which case more steps need to be taken. Its as simple as reimbursing the life points that were lost (or are going to be lost).

HaPpY sAdIsT said:
2: Knock back
This is a two part system. Firstly It detects, that when a unit is attacked, and takes damage from the attack, the unit is then pushed back a distance defined by a variable. While the unit is being pushed back, and for 1.5 seconds after, the unit's damage is reduced by 50% and its armour is reduced to 0.

You'll need a knockback system to begin with. I have one (and there are others you can find on the internet) that executes a fairly simple distance/time knockback (where distance and time are customizable specifications where as initial velocity/friction acceleration are not).

The other actions can be added additionally to the knockback system and does not have to be integrated.
 
Level 7
Joined
Jan 17, 2010
Messages
61
Paladon has an excellent GUI Knockback.

If you need a way of determining coordinates for your attacker to move to try this:

R=distance from original point (your unit) to unknown point (maybe distance between your unit and unit you're dodging + 5?)
r=distance from original point (your unit) to known point (unit you're dodging) in direction of unknown point

Original Point = (x.1 , y.1) (your unit)
Known Point = (x.2 , y.2) (unit you're dodging)
Unkown Point=(x.3 , y.3) (point you want to move to on other side of enemy)

This is the Y coordinate:
y.3 = y.1 + [(R(y.2-y.1))/r]

This is the X coordinate:
x.3 = x.1 + [(R(x.2-x.1))/r]

I've done this in GUI but I'm still learning how to post things on here, or I would have just posted the trigger.

//\\òó//\\
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
If you're lazy you could "teleport" the attacked unit to a point on the other side of the attacking unit. If you wanted a circular "slide" effect then you could easily do that too using timers and hashtables.

To post a trigger copy+paste within "[ TRIGGER ]" tags. The result is:

  • Yay.
To post JASS code then pastse it within "[ JASS ]" tags. The result is:

JASS:
Yay.

There are more, I'm sure there is some sort of tutorial on this.
 
Level 7
Joined
Jan 17, 2010
Messages
61
Berbanog said:
There are more, I'm sure there is some sort of tutorial on this.

Thanks for pointing out that a BB tutorial/help exists. It was a bitch navigating through the site to find it though.

Alright,
I'm not a spell coder so I make no promises as to how complete this would be, you seem to know more than I do, but this should help to get you started.
I did copy Critical Strike in Object Editor and made a custom called Slip Attack, then modified it. That's what is refered to in these triggers.


I made a quick map and (hopefully) put it in the Patebin if you want to look at it.

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Create 1 Town Hall for Player 1 (Red) at (Player 1 (Red) start location) facing Default building facing degrees
      • Unit - Hide (Last created unit)
      • Unit - Create 1 Mountain King for Player 1 (Red) at (Player 1 (Red) start location) facing Default building facing degrees
      • Unit - Create 1 Town Hall for Player 2 (Blue) at (Player 2 (Blue) start location) facing Default building facing degrees
      • Unit - Hide (Last created unit)
      • Unit - Create 1 Mountain King for Player 2 (Blue) at (Player 2 (Blue) start location) facing Default building facing degrees
      • -------- Set chance as a variable and determine elsewhere. Here it's 100% for testing. --------
      • Set chance = 100
  • Dodge01
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) is A Hero) Equal to True
      • ((Attacking unit) is A Hero) Equal to True
      • (Owner of (Attacked unit)) Equal to Player 1 (Red)
    • Actions
      • Set dodge = (Random integer number between 0 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • dodge Less than or equal to chance
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set Player01 = (Attacked unit)
          • Set Player01Enemy = (Attacking unit)
          • -------- Determine distance between units involved --------
          • Set rPlayer01 = (Integer((Distance between (Position of Player01Enemy) and (Position of Player01))))
          • -------- Set the distance for the unit attacked to move. Here it is 85 past the enemy, about where he would normally attack from. --------
          • Set RPlayer01 = (rPlayer01 + 85)
          • -------- The following formula determines the X and Y coordinates for the attacked unit to move to --------
          • -------- sets the point in a variable, then we run the action trigger to move the unit to that point --------
          • Set X01 = ((X of (Position of Player01)) + (((Real(RPlayer01)) x ((X of (Position of Player01Enemy)) - (X of (Position of Player01)))) / (Real(rPlayer01))))
          • Set Y01 = ((Y of (Position of Player01)) + (((Real(RPlayer01)) x ((Y of (Position of Player01Enemy)) - (Y of (Position of Player01)))) / (Real(rPlayer01))))
          • Set DodgeLoc01 = (Point(X01, Y01))
          • Set Player01speed = (Current movement speed of Player01)
          • Trigger - Run Dodge01a <gen> (checking conditions)
        • Else - Actions
  • Dodge01a
    • Events
    • Conditions
    • Actions
      • -------- I forced the enemy unit to pause while we move our unit --------
      • Unit - Pause Player01Enemy
      • -------- This a modified Critical Strike, check Object Editor --------
      • Unit - Add Slip Attack to Player01
      • -------- I thought this made him look more like he was "slipping" behind the enemy --------
      • Unit - Add Wind Walk to Player01
      • Unit - Set Player01 movement speed to 522.00
      • Unit - Order Player01 to Orc Blademaster - Wind Walk
      • Unit - Order Player01 to Move To (Point(X01, Y01))
      • -------- The wait gives him time to get in position --------
      • Wait 1.00 seconds
      • -------- We don't want him flying around after the initial "slip" --------
      • Unit - Remove Wind Walk buff from Player01
      • Unit - Remove Wind Walk from (Triggering unit)
      • Unit - Set Player01 movement speed to Player01speed
      • Wait 0.50 seconds
      • Unit - Unpause Player01Enemy
      • -------- We only want the first strike to be a critical hit --------
      • Unit - Remove Slip Attack from Player01
      • -------- Clean-Up --------
      • Custom script: call RemoveLocation (udg_DodgeLoc01)
      • -------- A cool down before turning the ability back on --------
      • Wait 15.00 seconds
      • Trigger - Turn on Dodge01 <gen>
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
OK, here's the dodge. It slides in a semi-circle behind the attacking unit and avoids damage from the attacker.

Let me know if this is OK.

I actually like the result a lot. I even added a chance for the unit to circle either from left or from right.
 

Attachments

  • Evasion_Slide.w3x
    22 KB · Views: 57
Last edited:
Level 19
Joined
Feb 4, 2009
Messages
1,313
OK, here's the dodge. It slides in a semi-circle behind the attacking unit and avoids damage from the attacker.

Let me know if this is OK.

I actually like the result a lot. I even added a chance for the unit to circle either from left or from right.

very nice but you forgot about the map borders
everybody forgets about the map borders
even I do! :grin:
 
Level 11
Joined
Apr 29, 2007
Messages
826
Or you could just use the following code to ensure the safety of all your stuff :)
  • BoundSentinel GUI
    • Events
      • Unit - A unit leaves (Playable map area)
    • Conditions
    • Actions
      • Custom script: set udg_BS_X = GetUnitX(GetTriggerUnit())
      • Custom script: set udg_BS_Y = GetUnitY(GetTriggerUnit())
      • Custom script: set udg_BS_Unit = GetTriggerUnit()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BS_X Greater than or equal to (Max X of (Playable map area))
        • Then - Actions
          • Custom script: call SetUnitX(udg_BS_Unit, GetRectMaxX(bj_mapInitialPlayableArea))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BS_X Less than or equal to (Min X of (Playable map area))
            • Then - Actions
              • Custom script: call SetUnitX(udg_BS_Unit, GetRectMinX(bj_mapInitialPlayableArea))
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BS_Y Greater than or equal to (Max Y of (Playable map area))
        • Then - Actions
          • Custom script: call SetUnitY(udg_BS_Unit, GetRectMaxY(bj_mapInitialPlayableArea))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BS_Y Less than or equal to (Min Y of (Playable map area))
            • Then - Actions
              • Custom script: call SetUnitY(udg_BS_Unit, GetRectMinY(bj_mapInitialPlayableArea))
            • Else - Actions
edit/ Ah just looked at your code after my post, seems like you did nearly the same.
 
Status
Not open for further replies.
Top