YesNoOk
avatar

Target Friction Cancel and Cornerpush. (Read 38265 times)

Started by inktrebuchet, March 22, 2020, 05:19:12 am
Share this topic:
Target Friction Cancel and Cornerpush.
New #1  March 22, 2020, 05:19:12 am
  • ****
    • USA
    • twitter.com/inktrebuchet
*NOT MADE FOR SIMUL MODE
This code is designed to cancel your opponents friction during hits. By doing this you can expect your opponent to be in the exact same spot after being hit, no matter what their friction is set to, so combos from one character to another are exactly the same.

The cornerpush code was only made afterwards, since this system doesn't work with existing versions. Vans’ corner push code was the one that I've always known about and was the one I studied for this. For more on his cornerpush code check out his characters and this article he wrote.

If you are wanting to use PoTS' or Vans' cornerpush code and not update hitdefs as described below, checkout this Friction Cancel/Replace version. It's a simple copy paste, no updates needed.

If anyone finds any bugs or ways to improve this code please let me know. Below is everything you'll need to get started.


Hitdefs can now have more accurate data to match source game. Since most games don't use velocity I've put together this example of how to properly write velocities to work with this system. You will need to grab slidetime and distance slid from source game, there's no need to adjust values to work with mugen here because with p2's friction canceled distance/time=velocity.
Code:
ground.slidetime = 9
ground.velocity = -(59 / 9)   ;distance / slide time
ground.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
air.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
down.cornerpush.veloff = 0

*The code below does use one variable. It doesn’t need to be a float variable, that’s just what I had available. Besides that, this can just be copy and pasted.

This goes in [statedef -2]
Code:
;================================================================================
; ------- Target friction cancel by Inktrebuchet --------
;================================================================================
[state friction cancel]
type = targetveladd
trigger1 = numtarget
trigger1 = target,movetype = H
trigger1 = fvar(37)>0 ; slide timer
trigger1 = target,statetype = S || target,statetype = C
trigger1 = target,vel x != 0
x = (enemynear,vel x / cond(enemynear,statetype = S, enemynear,const(movement.stand.friction), enemynear,const(movement.crouch.friction))) - enemynear,vel x
ignorehitpause = 1

;================================================================================
; ------- Cornerpush by Inktrebuchet. Guided by Vans cornerpush code.
;================================================================================
[state slidetime]
type = null
triggerall = numtarget
trigger1 = target,stateno = 5000 || target,stateno = 5070 ; custom hitstates can be added here if needed.
trigger1 = target,time = 0
trigger1 = fvar(37) := target,gethitvar(slidetime)
ignorehitpause = 1

[State -2, Push]
type = posadd
triggerall = numtarget
triggerall = (target, BackEdgeBodyDist <= 0) || (target, frontEdgeBodyDist <= 0)
triggerall = target,statetype != A || target,stateno = 5071 ; This allows cornerpush for trips.
triggerall = target,statetype != L
;trigger1 = stateno != ???? ;moves you do NOT want push back for.
;trigger1 = Statetype != A ; No Aerial attacks have cornerpush
trigger1 = HitPauseTime = 0
trigger1 = target,Hitshakeover
x = cond(fvar(37)>0 ,(target,gethitvar(xvel)*-facing),0 * (fvar(37) := 0))

[state slide timer]
type = null
triggerall = numtarget
trigger1 = HitPauseTime = 0
trigger1 = target,Hitshakeover
trigger1 = fvar(37) > 0
trigger1 = fvar(37) := fvar(37) - 1

Spoiler: re-testing this bit (click to see content)

Spoiler: Friction Cancel in Action (click to see content)
Spoiler: Cornerpush in Action (click to see content)
Last Edit: September 11, 2021, 04:36:47 am by inktrebuchet
Re: Target Friction Cancel and Cornerpush.
#2  March 22, 2020, 07:39:35 am
  • ****
  • CPU Purple Heart
    • USA
    • https://www.pixiv.net/en/users/8108265
 I've been waiting for this one and was curious how MUGEN handles hitsliding mathematically, but I do have a question. Suppose I don't use Vans' cornerpush system and use Phantom.of.the.Server's cornerpush system. Seeing as it doesn't use a slidetime-based timer, how would it be handled differently in that regard? To give an idea how his cornerpush code looks like, I'll post the code below that originally came from PotS' thread instead of the modified version I use so the solution can be shared with more people.

Spoiler, click to toggle visibilty

 Edit: Tried it for myself using PotS' cornerpush system and the friction cancel actually has no impact on it. I suspect the reason why is because PotS doesn't rely on slidetime, which is likely what made a world of difference here.
Last Edit: March 22, 2020, 12:04:37 pm by Nep Heart
Re: Target Friction Cancel/Replace
#3  March 22, 2020, 04:21:40 pm
  • ****
    • USA
    • twitter.com/inktrebuchet
Unfortunately, that wouldn't work the way you are thinking. There would be push but with that friction cancel version, hitdef velocities are much lower so without slidetime the pushback is much less than it should be. Part of the corner push is also needed for the friction cancel to work.

Below I've posted a version that has no cornerpush and it replaces your opponents friction with yours. So now you can use Pots or Vans' cornerpush code. You won't need to update your hitdefs as described in my first post either. This version will not match source games.

Code:
;================================================================================
; ------- Target friction cancel/replace by Inktrebuchet --------
;================================================================================
;Note: this version replaces opponents friction value with yours.
;For use with PoTS or Vans cornerpush only. Do not follow Inktrebuchet hitdef guide for this version.
[state friction cancel]
type = targetveladd
trigger1 = numtarget
trigger1 = target,movetype = H
trigger1 = target,statetype = S || target,statetype = C
trigger1 = target,vel x != 0
x = ((enemynear,vel x / cond(enemynear,statetype = S, enemynear,const(movement.stand.friction), enemynear,const(movement.crouch.friction))) * cond(enemynear,statetype = S, const(movement.stand.friction), const(movement.crouch.friction))) - enemynear, vel x
ignorehitpause = 1
Last Edit: April 07, 2020, 04:21:03 pm by ink
Re: Target Friction Cancel and Cornerpush.
#4  March 22, 2020, 08:16:06 pm
  • ****
  • CPU Purple Heart
    • USA
    • https://www.pixiv.net/en/users/8108265
 Nice, the solution is a lot simpler with PotS style cornerpush. You are right in regards to it not being 100% accurate, but the result is around 2 pixels off at worst and 0.3 pixels off at best, which isn't really so bad tbh. Since I strive more for function over accuracy, this does the job well enough for me.

 Thanks for the cooperation, this has been something that bugged me for a few months now.
Re: Target Friction Cancel and Cornerpush.
#5  April 07, 2020, 04:19:50 pm
  • ****
    • USA
    • twitter.com/inktrebuchet
Some small updates to 'Target Friction Cancel' redirects after checking out how Kamekaze used it in his Ultimate Falcon.

Replacing target with enemynear now allows for this system to work smoothly if you have multiple targets.