rotate.mac - a macro to control rotation speed

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

User avatar
Jon100
a hill giant
a hill giant
Posts: 161
Joined: Mon Sep 22, 2003 6:15 am
Location: UK

rotate.mac - a macro to control rotation speed

Post by Jon100 » Wed Nov 05, 2003 2:37 pm

A code snippet for controlling the speed of your character's rotation towards your current target.

I wrote this so I could rotate at higher speeds than /face normally allows, but without turning instantaniously, which I think looks suspicious to other players.

It probably needs a bit more polish, but feel free to use or modify it.


Code: Select all

| rotate.mac
| A macro to rotate you to face your current target at variable speeds
| Usage /macro rotate speed
|
|   where:
| speed 1 is very slow
| speed 5 is ~equal to /face
| speed 10 is very fast
| speed 20 is ultra fast
| speed >30 is ~ /face fast


#turbo

Sub Rotate

  /declare myheading local
  /declare targetbearing local

  /declare rotation local
  /declare mystep local
  /declare turn local

  /varset mystep @Param0
  /varset myheading $char(heading)
  /varset targetbearing $heading($target(y),$target(x))

  /varset turn $calc(@myheading-@targetbearing)

  /if n @turn<-180 /varadd turn 360
  /if n @turn>180 /varsub turn 360


  /if n @turn<0 {

	/if n @myheading>@targetbearing /varsub myheading 360

	/for rotation @myheading to @targetbearing step @mystep
	   /face heading @rotation nolook
|           /delay 0.5
	/next rotation

  } else {

	/if n @myheading<@targetbearing /varadd myheading 360

	/for rotation @myheading downto @targetbearing step @mystep
	   /face heading @rotation nlook
|           /delay 0.5
	/next rotation
  }

  /face fast nolook

/return