Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : General : Script function dx/dy of Orientation
New Topic New Poll Post Reply
Poster Message
larrymurk
Level: Smitemaster
Avatar
Rank Points: 1842
Registered: 12-09-2004
IP: Logged
icon Script function dx/dy of Orientation (0)  
Now that I'm doing some scripting I find that it'd be nice to have a simple way to get the x and y change for an orientation.

Right now I might code-
If Orientation=0 Then
dx=-1;dy=-1
If Orientation=1 Then
dx=0;dy=-1
..

What would be really nice-
Set Var dx XofO Orientation
Set Var dy YofO Orientation

So, when you add command Set Var I'd like to have the functions XofO and YofO available.

Obviously this is just for convenience. Please feel free to ignore this request:)
02-21-2013 at 05:50 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
Zch
Level: Smitemaster
Avatar
Rank Points: 503
Registered: 05-15-2007
IP: Logged
icon Re: Script function dx/dy of Orientation (+2)  
Hmm... I think you can "easily" get dx and dy from orientation.

Label Start
Wait for event Player swings weapon
Set var "dy" = _O
Set var "dy" / 3
Set var "dy" - 1
Set var "dx" = _O
Set var "dx" % 3
Set var "dx" - 1
Speech "dx: $dx$ dy: $dy$",Normal,Beethro,0,.
Wait 0
Go to Start

I have been kinda stuck with some scripts myself, and only realized I could do this after reading your feature request...

Edit: no, what I needed was not this, it was something else...

[Last edited by Zch at 02-21-2013 06:48 PM]
02-21-2013 at 06:33 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
TFMurphy
Level: Smitemaster
Rank Points: 3021
Registered: 06-11-2007
IP: Logged
icon Re: Script function dx/dy of Orientation (+2)  
Even easier than that:
Set var "dy" = _O/3 - 1
Set var "dx" = _O%3 - 1

So yeah, not a huge need for this.

02-21-2013 at 06:58 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
larrymurk
Level: Smitemaster
Avatar
Rank Points: 1842
Registered: 12-09-2004
IP: Logged
icon Re: Script function dx/dy of Orientation (0)  
very nice, ty guys.

My scripts will look much prettier:)

02-21-2013 at 07:04 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 2323
Registered: 12-28-2004
IP: Logged
icon Re: Script function dx/dy of Orientation (0)  
How about adding some predefined functions to the expressions actually?

So:

Set Var myVar = xOfO(1) + yOfO(2) + sqrt(3) + random(7)


I am not sure how much work it would be to add support for them though.

____________________________
I am a skelliopath.
02-21-2013 at 07:36 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 4335
Registered: 02-04-2003
IP: Logged
icon Re: Script function dx/dy of Orientation (0)  
Uhh....nah....

____________________________
Gandalf? Yes... That's what they
used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the
turn of the tide.
02-21-2013 at 07:45 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
larrymurk
Level: Smitemaster
Avatar
Rank Points: 1842
Registered: 12-09-2004
IP: Logged
icon Re: Script function dx/dy of Orientation (0)  
Can someone move this thread to a more useful place like general so the community can benefit from it?
02-22-2013 at 10:40 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 3210
Registered: 02-20-2007
IP: Logged
icon Re: Script function dx/dy of Orientation (+1)  
You may find this topic helpful. It contains the above formulas and a few more ;)

____________________________
50th Skywatcher
02-23-2013 at 04:29 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
uncopy2002
Level: Smiter
Rank Points: 387
Registered: 07-28-2014
IP: Logged
icon Re: Script function dx/dy of Orientation (+5)  
I also happen to have some snippets that should be useful.

Dot product and cross product of two vectors as orientations, Ou and Ov:

  Set var "dotP" = ((Ou/3-1)*(Ov/3-1) + (Ou%3-1)*(Ov%3-1)) * (1+(Ou%2)*(Ov%2))

  Set var "crossP" = ((Ou/3-1)*(Ov%3-1) - (Ou%3-1)*(Ov/3-1)) * (1+(Ou%2)*(Ov%2))


This should return an integer between -2 to 2: for dot product, parallel vectors give 2, 45/135 degrees angle inbetween gives 1/-1, perpendicular vectors give 0, and antiparallel vectors give -2. Cross product is more or less the same, but with usual cross product rules and right-hand rule compliant.

Practical use: Check things with directional dependence, especially force arrow blocking checks, without tons of if checks.



Oh, and also magic formulae to convert ArrowO and TunnelO to _O:

ArrowO to _O
  Set var ".O" =  ( (ArrowO-4)%8 - 2*((ArrowO-17)%3)*(ArrowO/14) + ((-2*(ArrowO/15))+(4*(ArrowO/16))-(2*(ArrowO/19))) )%9


TunnelO to _O
  Set var "_O" = 4 + 1*(((TunnelO-56)/6+1)/2)*((TunnelO%2)*2-1) + 3*(((TunnelO-56)/6-1)/2)*((TunnelO%2)*2-1)


Note: TSS arrows are ranged from 13-20, not 12-19. So just add every value for the arrows in the above topic Nuntar linked by 1. i.e:

 Arrows    Tunnels       _O
20 13 14      47       0  1  2
19    15   64    63    3     5
18 17 16      48       6  7  8


[Last edited by uncopy2002 at 12-19-2016 12:55 PM]
12-19-2016 at 12:31 PM
View Profile Send Private Message to User Show all user's posts High Scores Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : General : Script function dx/dy of Orientation
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.