| 1 |
import Crossfire |
| 2 |
import CFWorld |
| 3 |
import math |
| 4 |
|
| 5 |
scorn_loc = (5272, 5786) |
| 6 |
navar_loc = (6112, 5850) |
| 7 |
|
| 8 |
Crossfire.SetReturnValue( 1 ) |
| 9 |
|
| 10 |
def getdiff(loc1, loc2): |
| 11 |
return (loc1[0]-loc2[0], loc1[1]-loc2[1]) |
| 12 |
|
| 13 |
def getdir(loc1, loc2): |
| 14 |
loc = getdiff(loc1, loc2) |
| 15 |
if (loc[1] > 0): |
| 16 |
start="south" |
| 17 |
elif(loc[1] < 0): |
| 18 |
start="north" |
| 19 |
else: |
| 20 |
start="" |
| 21 |
if (loc[0] > 0): |
| 22 |
return start+"east" |
| 23 |
elif(loc[0] < 0): |
| 24 |
return start+"west" |
| 25 |
else: |
| 26 |
return start |
| 27 |
|
| 28 |
#outputs in furlongs (outdoor tiles) |
| 29 |
def getdist(loc1, loc2): |
| 30 |
loc = getdiff(loc1, loc2) |
| 31 |
return int(math.sqrt((loc[0]*loc[0])+(loc[1]*loc[1]))) |
| 32 |
|
| 33 |
#outputs in miles |
| 34 |
def getuserdist(dist): |
| 35 |
return (int(dist/8.0+0.5)) |
| 36 |
|
| 37 |
def gettext(loc1, loc2, name): |
| 38 |
loc_raw_dist = getdist(loc1, loc2) |
| 39 |
loc_dist = getuserdist(loc_raw_dist) |
| 40 |
loc_dir = getdir(loc2, loc1) |
| 41 |
if (abs(loc_dist) > 5): |
| 42 |
loc_distmsg = "A "+name+" arrow flashes "+str(loc_dist)+" times" |
| 43 |
else: |
| 44 |
loc_distmsg = "A "+name+" arrow glows steady" |
| 45 |
if (loc_raw_dist): |
| 46 |
loc_distmsg += ", pointing to the "+loc_dir+"." |
| 47 |
else: |
| 48 |
loc_distmsg += ", spinning in one place." |
| 49 |
return loc_distmsg |
| 50 |
|
| 51 |
pl = Crossfire.WhoIsActivator() |
| 52 |
me = Crossfire.WhoAmI() |
| 53 |
|
| 54 |
location = CFWorld.loc_from_ob(pl) |
| 55 |
if (location): |
| 56 |
scorntxt = gettext(location, scorn_loc, "red") |
| 57 |
navartxt = gettext(location, navar_loc, "blue") |
| 58 |
pl.Write(scorntxt+" "+navartxt) |
| 59 |
else: |
| 60 |
pl.Write("The amulet doesn't seem to work here.") |