ID:176660
 
I am trying to make it so that the eye is always looking two spaces in front of the player. Could someone please help?
I have this so far:

mob
proc
Eye()
if(src.dir == NORTH)
client.eye = locate(x,y+2,z)
if(src.dir == SOUTH)
client.eye = locate(x,y-2,z)
if(src.dir == EAST)
client.eye = locate(x-2,y,z)
if(src.dir == WEST)
client.eye = locate(x+2,y,z)
Ticker()
spawn while(1)
sleep(3)
Eye()
New()
if(client)
Ticker()

Also, could someone work out why this verb won't work?

Take_Off()
set src in usr
usr.overlays -= src
usr << "You take the [src] off"
src.suffix = null

The suffix changes, but the overlay isn't removed.

Thanks in advance
Im an idiot so i dont know what im doing, i think you want
client
lazy_eye = 2

but im a idiot so i dont' know.
In response to Metallica
Not quite what I want. I'm trying to make it so that your guy isn't at the centre of your screen. If you're looking north, the screen is 2 spaces north and if you're looking east, the screen is 2 spaces east etc.
In response to Hazman
yeah that's what lazy_eye does
In response to Metallica
lazy_eye just sets the distance you can travel before the camera centres on you again, so If I set lazy_eye to 4, I'd have to move 4 spaces before the camera centred on me again.
In response to Hazman
lazy eye, thats a funny thing, i thought he was joking when i read his post, lol.
Try look at Nadrews tutorial/library on Client.eye
In response to Maz
I checked out Nadrews portfolio and the library/thing you are refering to is non-existant.
client
North()
usr.client.eye=locate(usr.x,usr.y+2,usr.z)
..()
South()
usr.client.eye = locate(usr.x,usr.y-2,usr.z)
..()
East()
usr.client.eye = locate(usr.x-2,usr.y,usr.z)
..()
West()
usr.client.eye = locate(usr.x+2,usr.y,usr.z)
..()


RaeKwon
In response to RaeKwon
My suggestion would be to create an obj to go along with this, for any mob who has a client. Make it change positions any time the mob moves.
obj/eye
// no icon (unless you want one for some reason)
var/mob/owner
var/atom/position
var/adjusting=0 // moving smoothly
var/speed=4 // number of ticks between tiles; adjust to preference

New(newloc,mob/M)
if(!M || !M.client) del(src)
owner=M
M.client.eye=src
FindPosition()

proc/FindPosition()
if(!owner || !owner.client || owner.client.eye!=src)
del(src)
var/idealx=owner.x
if(!idealx) return null // owner is at null
var/idealy=owner.y
if(owner.dir&EAST) idealx+=2
else if(owner.dir&WEST) idealx-=2
if(owner.dir&NORTH) idealy+=2
else if(owner.dir&SOUTH) idealy-=2
idealx=max(world.view+1,min(world.maxx-world.view,idealx))
idealy=max(world.view+1,min(world.maxy-world.view,idealy))
position=locate(idealx,idealy,owner.z)
if(!loc || !position || loc.z!=position.z || loc==position)
loc=position
else
if(adjusting) return // already on the move
var/n=get_dist(loc,position)
pixel_step_size=max(1,min(32,round(32*n/speed,1)))
loc=get_step_towards(loc,position)
if(position!=loc) // still not there, so keep going
spawn(round(speed/n)) FindPosition()
return
adjusting=0

mob
Move()
var/olddir=dir
.=..()
if(. || dir!=olddir) MoveEye()

proc/MoveEye()
if(client)
var/obj/eye/E=client.eye
if(E==src) E=new/obj/eye(loc,src)
else E.FindPosition() // move to the new position
The trick is that every time you set mob.loc manually or change direction, you have to call MoveEye() still to move the eye; but you'd be stuck doing that anyway.

The nice thing about this system is that the eye will adapt to direction changes smoothly, without jerking about. It will move more quickly when a bigger change is needed, however, so that if you turn and start walking it should (in theory) catch up.

Lummox JR
In response to Lummox JR
Thanks Lummox JR, but I think I'll go with RaeKwon for ease.
*Says in Jackie-Chan Adventures Uncle style* One more thing.

How could you use the HUD to make some sort of highlight for your character, like a ring around him/her/it or something
In response to Hazman
You'd have to use image() for that, look it up, you should get the idea.
In response to Lummox JR
The nice thing about this system is that the eye will adapt to direction changes smoothly, without jerking about.

Ingenious... that's a feature I've wanted for a long time, and it never occurred to me that simply using an invisible dummy obj would suffice.
In response to Lummox JR
You also might want to set the eye's animate_movement to SYNC_STEPS, so that the eye is in step with the mob.
In response to Lummox JR
For some reason, the eye jumps about for me when I change direction. Can you help?
In response to Hazman
Hazman wrote:
How could you use the HUD to make some sort of highlight for your character, like a ring around him/her/it or something

Images would work nicely, as Nadrew suggested. The way I'd do it would be to create 4 icons for the 4 quarters of a circle, set up as directional icons with diagonal directions.
highlight
var/atom/target
var/list/images

Del()
if(images)
for(var/I in images) del(I)
..()

ShowTo(client/C)
C.images-=images // remove images from client.images (to be safe)
C.images+=images // and re-add them

HideFrom(client/C)
C.images-=images // remove images from client.images

highlight/circle
New(atom/A,client/C)
target=A
images=new
var/image/I
for(var/d in list(NORTHEAST,NORTHWEST,SOUTHEAST,SOUTHWEST))
I=new(icon='circle.dmi',loc=A,layer=TURF_LAYER+1,dir=d)
I.pixel_x=d&EAST?16:-16
I.pixel_y=d&NORTH?16:-16
images+=I
if(C) ShowTo(C)
This is just an example of how you might do that. I like to use datums for any collection of objects like this because it automates the process of deleting it.

Lummox JR
In response to Garthor
That sounds like a good idea too! Thanks.
In response to Hazman
Hazman wrote:
For some reason, the eye jumps about for me when I change direction. Can you help?

In my code the eye should move fairly quickly but I wouldn't have thought instantly. One thing I suppose you could do is use n=min(n,1.5), so the "extra" speed is never more than a little above average.

Lummox JR
In response to Lummox JR
Also, I cn't call MoveEye() for some reason. It says that the proc doesn't exist.