YesNoOk
avatar

Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate? (Read 699 times)

Started by altoiddealer, November 15, 2014, 05:43:15 am
Share this topic:
Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate?
#1  November 15, 2014, 05:43:15 am
  • **
    • USA
    • altoiddealer@gmail.com
Anyone following the progress of my char probably saw that I have made a custom feature, where my character's eyes follow P2 during the fight.

Currently, my varsets are triggered by comparing P2's axis with P1's axis (p2dist x and p2dist y).  He will also look down if P2 is in a "crouch type" state, or if in the typical crouching statenos. (if you look at the code, plz ignore my not adding typical crouch-attack statenos yet to it).

At this point, the effect only looks natural vs. average height characters, during maybe 75% of P2's states.

For instance here's one stupid thing I noticed against one char: the author did not assign the "crouch type" value to his crouch attacks, so Jailbot's eyes shot up every time p2 did a crouching attack (you know what I mean...).


Unless I'm missing something, I don't think there's a simple way to really solve this; I'm sure it will have to be a combination of techniques.  I don't know if I'm better off using a helper sometimes?  I almost feel like I'm a little over my head here - this is my first character so I'm still a bit wet behind the ears.

...is there an experienced coder that might know that winning combination I need? :???:

I could probably just keep adding down and dirty workarounds, brute-forcing every issue away one by one, but I'm afraid I'll spin this big complex web and just get lost in it  :knife:

Spoiler: code (click to see content)

Re: Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate?
#2  November 15, 2014, 12:46:06 pm
  • ***
    • USA
One idea would be to make a type of vertical pushblock helper. It'd take up some resources I think..
But make a blank animation with just a flat blue bar. (FF3) Make a helper and use it as it's anim.
You could set it to move down until it made contact with P2. Then you'd use it's position and find the general "top" of P2.
One thing would be like Ryu's crouching uppercut. The top of the fist would become the top of the character, so P1 still might have the problems you're describing.

If a creator of a character mislabels moves, I dont know how you should be responsible to code around it.
you could always do something like

[State -2, adjustvar]
type=varset
triggerall=numenemy
trigger1=enemy,name="cvsvega"&&(enemy,authorname="Warusaki3"||enemy,authorname="Gargoyle")

and list people with problems.
           
Re: Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate?
#3  November 15, 2014, 01:10:13 pm
  • *****
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net

  • Online
You can also use Enemy,Const(size.head.pos.y)

It will return the position of the head, based on the character's CNS. It will not return the current Pos Y of the character's head, so it will be the same if the enemy is jumping or crouching

However, you can play with this value by offsetting it with the character's axis. If the axis is higher than the head.pos.y, then the character is jumping
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
Re: Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate?
#4  November 15, 2014, 03:03:38 pm
  • **
    • USA
    • altoiddealer@gmail.com
One idea would be to make a type of vertical pushblock helper. It'd take up some resources I think..
But make a blank animation with just a flat blue bar. (FF3) Make a helper and use it as it's anim.
You could set it to move down until it made contact with P2. Then you'd use it's position and find the general "top" of P2.
One thing would be like Ryu's crouching uppercut. The top of the fist would become the top of the character, so P1 still might have the problems you're describing.

If a creator of a character mislabels moves, I dont know how you should be responsible to code around it.
you could always do something like

[State -2, adjustvar]
type=varset
triggerall=numenemy
trigger1=enemy,name="cvsvega"&&(enemy,authorname="Warusaki3"||enemy,authorname="Gargoyle")

and list people with problems.

Thanks, I definitely never would have thought of this.  That's interesting!
If I stay with the crouch-type move triggers, I think I'll do as you suggested to hack a solution

You can also use Enemy,Const(size.head.pos.y)

It will return the position of the head, based on the character's CNS. It will not return the current Pos Y of the character's head, so it will be the same if the enemy is jumping or crouching

However, you can play with this value by offsetting it with the character's axis. If the axis is higher than the head.pos.y, then the character is jumping

Hmm... so if I just factor this in I think that could help with my player height issue



I appreciate the feedback guys!  Anyone else have a tip?
Re: Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate?
#5  November 16, 2014, 12:14:07 am
  • ****
  • Hey.
    • Ukraine
    • mugencoder.com

  • Online
Another way that comes to mind that could added on top of what you have already is by detecting the stateno and prevstateno of your enemy. For example:

Code:
trigger1 = (enemynear(0),stateno=[10,12]) || (enemynear(0),prevstateno=[10,12]) ; If they're crouching or were crouching in the last state.

Most characters don't really have crouching chains, so usually, you'd see 11->400->11 for a simple crouching attack.

-[Все слова это только слова.]-
Re: Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate?
#6  November 16, 2014, 04:17:32 pm
  • **
    • USA
    • altoiddealer@gmail.com
Another way that comes to mind that could added on top of what you have already is by detecting the stateno and prevstateno of your enemy. For example:

Code:
trigger1 = (enemynear(0),stateno=[10,12]) || (enemynear(0),prevstateno=[10,12]) ; If they're crouching or were crouching in the last state.

Most characters don't really have crouching chains, so usually, you'd see 11->400->11 for a simple crouching attack.

That's a good point and awesome suggestion.  This will def reduce the chances of that lookup issue against the "undeclared-crouch-type" chars :)  Thanks again!

Of course I'll also be adding P2StateNo != 0  to that condition, so it doesn't continue triggering if p2 just stops crouching.


Quick question... what is enemynear(0)?  I underatand redirects but is there a significance for the zero? Or is that a placeholder for the ID of P2?   I've avoided this redirection bc Im not sure exactly how you obtain the id number, or how/when this is more practical/different from just "enemy."
Last Edit: November 16, 2014, 04:23:45 pm by altoiddealer
Re: Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate?
#7  November 16, 2014, 05:04:49 pm
  • ****
  • Hey.
    • Ukraine
    • mugencoder.com

  • Online
Quick question... what is enemynear(0)?  I underatand redirects but is there a significance for the zero? Or is that a placeholder for the ID of P2?   I've avoided this redirection bc Im not sure exactly how you obtain the id number, or how/when this is more practical/different from just "enemy."
enemynear(0) is the same thing as enemynear. "0" means that it will be redirecting to the nearest enemy to you. enemynear(1) would redirect to the second nearest enemy to you. Think of the number as more of an index than an ID. enemy redirects to the first enemy found. Similar to enemy(0) while enemy(1) redirects to the second enemy found. The major difference between enemy and enemynear is the "near" part. Sometimes you'd want to know who's closest to you, while other times you'd rather know who is the second enemy. On a final note, using enemynear and enemynear(0), do the same thing, but it's basically user preference at that point. Personally, I use both, but usually am using enemynear(0). It's a force of habit I suppose. XD Hope that clears this up for you. :)


-[Все слова это только слова.]-
Re: Calculating X/Y distance, relative to P1's and P2's faces? Or close estimate?
#8  November 16, 2014, 08:53:04 pm
  • **
    • USA
    • altoiddealer@gmail.com
Thanks for the explanation!  I'll be using that redirection for sure.