PDA

View Full Version : Checking if a combo is above/below/to the left of/to the right of Link?



Nimono
09-25-2007, 10:31 AM
Let me explain what I mean in the title...

I'm working on a script for someone.. The Magnetic Gloves script. I don't like using FFCs to denote where the combo should be, so I'm trying to use Combos. For facing north, I need to check if the combo's X equals Link's X and if it's Y is lower than Link's Y. If so, it'd move Link up a few pixels at a time as long as the item is being used.... An FFC would HAVE to be used here to keep Link from activating Warp combos or Damage combos. (I've learned that FFCs with combos of combo type "None" overwrite the combo's combo type on Layer 0, which makes things interesting.) Here's the problem- I can't just set them relative to Link's X and Y. I know it'd be super-simple if I used FFCs, but then the user would have to set them on a per-screen basis, which might turn the user away from using the script. I could check each combo location individually, but that'd be a ton of unnecessary code. Anyone got a solution? 'Cause I'm out of options, and there'd be nothing that I could do that I can think of that won't be annoying for either me or the end user. >_<

Thanks in advance. Oh yeah, and don't tell me that the script's impossible- Like I said, I could just use FFCs to denote where the combo is. :p

C-Dawg
09-25-2007, 11:30 AM
If you want the designer to be able to tell the script which locations on the screen react to the magnetic gloves, you really only have three options:

Put an FFC there (you don't want to do this).

or

Let the user put information into the D0-D7 fields specifying up to four X,Y locations on the screen.

or

Check all of the combos on the screen within the item's area of effect when it is used to see if they have a certain combo. This isn't very hard. If the gloves only work in a straight line in front of the player, you just need to check the Data for each combo in front of him. You'd do this:
1. Get the player's X,Y
2. Get the player's direction
3. Snap the X,Y to the nearest 16x16 grid
4. Find the combo the player is on
5. Check the combos in a line from the player going in the direction the player is facing.
6. If you find a magnetic combo, react!

or

Do what I'm doing. I'm working on something similar - a more robust hookshot. The idea is that this Hookshot would be an FFC that shoots out in front of the player, and when it hits a particular combo (it checks the combos nearby) it will yank the player towards it. As long as the button is held, of course. Sort of like how the grappler worked in Quake 2. The normal hookshot is too cumbersome for sidescrollers. If you don't want the grappling FFC to show up, just make it invisible. Moving the FFC and checking around it is a fast way to scan for the combo you want.

Nimono
09-25-2007, 01:15 PM
Check all of the combos on the screen within the item's area of effect when it is used to see if they have a certain combo. This isn't very hard. If the gloves only work in a straight line in front of the player, you just need to check the Data for each combo in front of him. You'd do this:
1. Get the player's X,Y
2. Get the player's direction
3. Snap the X,Y to the nearest 16x16 grid
4. Find the combo the player is on
5. Check the combos in a line from the player going in the direction the player is facing.
6. If you find a magnetic combo, react!
That's exactly what I want it to do. There's one problem- Edge of Screen. I guess I could just keep adding/subtracting 16 and constantly check for if it reaches the edge, huh? If that's not what you were thinking of, would you mind explaining it to me?


I'm working on something similar - a more robust hookshot. The idea is that this Hookshot would be an FFC that shoots out in front of the player, and when it hits a particular combo (it checks the combos nearby) it will yank the player towards it. As long as the button is held, of course. Sort of like how the grappler worked in Quake 2. The normal hookshot is too cumbersome for sidescrollers. If you don't want the grappling FFC to show up, just make it invisible. Moving the FFC and checking around it is a fast way to scan for the combo you want.
That's similiar to what I'm doing. Except it instantly latches onto any magnetic combos if they're in a straight line from Link in the direction he's facing... As long as you hold A or B down, the script that makes it work stays active...

Oh yeah, speaking of that, do you know of a better way to check if A or B is being used AND the current item is the Magnetic Gloves than simply turning off the other button if one is pressed? (I want to keep the player from activating the item and pressing the other button to use it...)

Praethus
09-25-2007, 02:12 PM
Make your item script change a global variable MAGNET_GLOVE_ON to true. Then your Global Script can check that MAGNET_GLOVE_ON is true and the button is still down. If the button is released, set the global variable to false again. While both are true, move Link toward the magnet point.

Also, to avoid damage/warp combos, you can simply set Link's Z variable to something above 0 every frame.

C-Dawg
09-25-2007, 04:05 PM
When you activate the item, two things happen:
1. Global variable Magnet_glove_used is set to true.
2. Global variable Magent_glove_button is set to A or B depending on which button was used to activate the item.

Then your global/ffc script does this:
1. While Magnet_glove_used is true, it does the magnet effect.
2. Checks whether Magnet_glove_button is still held down. If not, end the effect by setting Magnet_glove_used to false.
3. If the player hits start, L, or R (changing items, possibly changing away from the glove) end the effect, too.

Nimono
09-25-2007, 04:45 PM
When you activate the item, two things happen:
1. Global variable Magnet_glove_used is set to true.
2. Global variable Magent_glove_button is set to A or B depending on which button was used to activate the item.

Then your global/ffc script does this:
1. While Magnet_glove_used is true, it does the magnet effect.
2. Checks whether Magnet_glove_button is still held down. If not, end the effect by setting Magnet_glove_used to false.
3. If the player hits start, L, or R (changing items, possibly changing away from the glove) end the effect, too.

I don't wanna do that, really. The person I'm making it for, Shoelace, doesn't want the player to be able to stop the item except by releasing the button. ESPECIALLY since it's supposed to switch polarity. >_<

Now, someone wanna explain to me a good way to check for the combos, while also checking if it's the edge of the screen? (Hey, someone might do it.)

C-Dawg
09-25-2007, 09:34 PM
I don't wanna do that, really. The person I'm making it for, Shoelace, doesn't want the player to be able to stop the item except by releasing the button. ESPECIALLY since it's supposed to switch polarity. >_<

Then you're screwed. There is no way to check if the player still has the gloves selected. If you don't stop the effect when the player hits a button that could change the current item (except when Link is being pulled over a pit or something, obviously) then the player can activate the glove, hold down A, switch items, and continue using it.



Now, someone wanna explain to me a good way to check for the combos, while also checking if it's the edge of the screen? (Hey, someone might do it.)

You've been told several ways already. See above. As for knowing when you're at the edge of the screen, that's simple. Just keep checking till the x or y coordinate is off of the visible area.

Nimono
09-26-2007, 11:58 AM
Then you're screwed. There is no way to check if the player still has the gloves selected. If you don't stop the effect when the player hits a button that could change the current item (except when Link is being pulled over a pit or something, obviously) then the player can activate the glove, hold down A, switch items, and continue using it.
Not really. Can't I just disable those buttons when the other is pressed? (Like, B disables A, L, and R for as long as it's held, and B, L, and R for A.) Like I'm doing now?



You've been told several ways already. See above. As for knowing when you're at the edge of the screen, that's simple. Just keep checking till the x or y coordinate is off of the visible area.
Eh, okay. Thanks for the help. >_>