Jump to content

Photo

Best way to script "if lweapon is EXACTLY CENTERED on combo y"


  • Please log in to reply
9 replies to this topic

#1 idontknow8

idontknow8

    Senior

  • Members

Posted 16 February 2017 - 06:25 PM

I'm trying to make a Spinner (like from Twilight Princess) type item and it kinda works but pretty buggy.  I basically want to make it so that when the spinner (which is basically a lweapon 2 tiles tall by 1 tile wide that looks like Link on top of the spinner (but Link is actually invisible).  When this lweapon hits a certain combo, it will change direction (I have a different combo for going left, right, up, down, & stopping).

 

 While the script I have complies fine, the problem is that it seems to change direction immediately upon hitting the combo instead of being centered directly over it.

 

Any thoughts as to how I might go about doing this?  I'm not at the same computer as my script so I don't have it in front of me now but I believe I'm currently use if(Screen->ComboD(ComboAt(spinner->X + 8, spinner->Y + 16)

 

(The spinner is 16 pixels wide by 32 pixels tall so for it to be centered would be half of that...so that's why I used the above numbers 8 & 16).

 

Sorta confusing to describe.  Sorry.  Anybody follow?  Have any suggestions?



#2 grayswandir

grayswandir

    semi-genius

  • ZC Developers

Posted 16 February 2017 - 07:20 PM

You can use if(spinner->X % 16 == 0 && spinner->Y % 16 == 0) to tell if the spinner is exactly aligned with a tile. Once you've tested that, you can use your current test to see if you want to change.

 

Also, you might want Y + 24 instead of 16, to get the center of the bottom tile instead of the edge between the two. It won't matter if you're just checking when the tile aligns, though.



#3 idontknow8

idontknow8

    Senior

  • Members

Posted 16 February 2017 - 11:42 PM

What does % do in a script?



#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 17 February 2017 - 02:25 AM

What does % do in a script?

 

% is the modulus token. In mathematics, it returns the remainder of integer division:

 

int 12 / 10 = 1 : in integer division, the true result of 1.2 is truncated to 1.

int 12 % 10 = 2 : Thus, you can get the remainder of the integer as a result of the division with modulus.

 

That is, 12/10 = 1, remainder 2.



#5 idontknow8

idontknow8

    Senior

  • Members

Posted 17 February 2017 - 09:52 AM

Gotcha.  Also, is there a way to determine the absolute value of an integer?



#6 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 17 February 2017 - 12:41 PM

Abs(int); will get you the absolute value of an int.

#7 idontknow8

idontknow8

    Senior

  • Members

Posted 17 February 2017 - 02:29 PM

Well dang, that's a no-brainer!  lol.  Thank you!



#8 idontknow8

idontknow8

    Senior

  • Members

Posted 17 February 2017 - 03:36 PM

Hmm... this is still kinda buggy.  Any simpler way to script a Spinner type item? 

 

Basically there's two parts/things it can do:

 

When it's not on a "track" type combo, the spinner spins in place, with Link on top, which damages nearby enemies (enemies directly next to it on all four cardinal directions).  This consumes a little bit of magic and only spins for like a second, maybe two.  Then it stops and Link appears as normal.

 

When it's on a "track" type combo, Link appears on top of the spinner & the two are launched in the direction of the track, which I think of very much like a raft path in that you can lay down the path and it can keep turning in a number of directions.  However, unlike the raft, the spinner is also an lweapon so it damages enemies too.  When it hits a certain combo, the spinner will stop and disappear.

 

I got the first part to happen fine.  Getting the spinner track to work properly seems to be a big issue.



#9 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 17 February 2017 - 05:21 PM

I would suggest taking a page from TP on this. When Link is close enough to the track have him snap to it and take direct control via script. After that it's literally about scripting path following algorithms, not to difficult.

#10 idontknow8

idontknow8

    Senior

  • Members

Posted 17 February 2017 - 07:06 PM

Not sure how to do that - both find the distance between Link & the combo and how to snap him to the combo.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users