Thread: Mouse Movement
View Single Post
  #8  
Old 05-04-2002, 01:23 AM
TDO2000 TDO2000 is offline
Registered User
TDO2000's Avatar
Join Date: Jul 2001
Location: Germany
Posts: 655
TDO2000 is on a distinguished road
Quote:
Originally posted by Kaimetsu
I really want to post my gesture recognition system, but y'know, script stealing and all
hmmmm sounds like B&W

hmmmm Graal need something like the UO-movement-System
I prefer it that way ^-^

something like this (but with a better onwall-check etc)
I have just invested 2-3 minutes to test the new mouse commands

NPC Code:

//Small UO-Like Walking System
if (playerenters || created) {
if (!isweapon) toweapons System;
else {
this.xy={playerx,playery};
disabledefmovement;
timeout=.05;
}
}

if (timeout) {
//showing the cursor
showimg 201,@<->,mousex,mousey;
//Checking for a key pressed
if (leftmousebutton) movechar();
else if (strequals(#m,walk)) setani idle,;
timeout=.05;
}

function movechar() {
setani walk,;
//getting Distance
this.distance = ((playerx-mousex)^2+(playery-mousey)^2)^.5;
//Getting the Playerdir
dx = playerx - mousex;
dy = playery - mousey;
if (abs(dx)>abs(dy)) {
if (dx>0) playerdir=1; else playerdir=3;
} else {
if (dy>0) playerdir=0; else playerdir=2;
}
//getting speedvar
if (this.distance < 5) this.speed = .3;
if (this.distance in |5,10|) this.speed = .5;
if (this.distance > 10) this.speed = .7;
//move the player
len = (dx*dx+dy*dy)^0.5;
addx = (dx/len)*this.speed;
addy = (dy/len)*this.speed;
if (!onwall(playerx+1.5+vecx(playerdir)*1.025,playery +2+vecy(playerdir)*1.025)) {
playerx-=addx;
playery-=addy;
}
}


use it, flame it or do whatever you want
__________________
No Webhost at the moment
Reply With Quote