Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Mouse Movement (https://forums.graalonline.com/forums/showthread.php?t=28443)

Glory 05-02-2002 01:56 PM

Mouse Movement
 
Kumada wanted me to post this,
Kumada:
Here is a movement script for the new version.. its not
completely done yet but it should at least show you how to use
some of the new commands.

NPC Code:
	
// NPC made by Kumada
if (playerenters || timeout){
if (leftmousebutton){
setani walk,;
this.walktox = mousex;
this.walktoy = mousey;
showimg 1,@Moving to x#v(this.walktox)
y#v(this.walktoy),this.walktox,this.walktoy;
for (; this.walktox>playerx; playerx++; ){
playerdir = 3;
sleep 0.05;
}
for (; this.walktox<playerx; playerx--; ){
playerdir = 1;
sleep 0.05;
}
for (; this.walktoy>playery; playery++; ){
playerdir = 2;
sleep 0.05;
}
for (; this.walktoy<playery; playery--; ){
playerdir = 0;
sleep 0.05;
}
}
timeout = 0.05;
}


Saga2001 05-02-2002 02:34 PM

While were showing off mouse scripts...I got bored and made this...its cool. :) Won't work w/o npc server (well some of it will..)
NPC Code:

if (actionserverside) {
if (strequals(#p(0),getPlayer)) {
with (getplayer(#p(1))) {
setstring thiso.player,#a;
thiso.hearts = playerhearts;
thiso.fhearts = playerfullhearts;
thiso.ap = playerap;
thiso.mp = playermp;
}
setstring clientr.playermenu,"#s(this.player)'s Status","Hearts #v(thiso.hearts)/#v(thiso.fhearts)","AP: #v(thiso.ap)","MP: #v(thiso.mp)";
}
}
//#CLIENTSIDE
if (playerenters || timeout) {
if (strlen(#s(client.colors))<=0) setstring client.colors,.2 .5 .9 1;
tokenize #s(client.colors);
this.r = strtofloat(#t(1));
this.g = strtofloat(#t(2));
this.b = strtofloat(#t(3));
this.a = strtofloat(#t(4));
getPlayer();
if (this.on == 1)
setstring this.menuitems,Status,"Hearts #v(playerhearts)/#v(playerfullhearts)","AP: #v(playerap)","MP: #v(playermp)";
if (this.wait>5) {
if (this.on == 1) updateDropdown();
if (mousebuttons == 1 && this.lock == 0) showDropdown();
if (mousebuttons == 4) hideDropdown();
if (mousewheeldelta!=0 && this.on == 1) {this.y+=(mousewheeldelta*25);moveDropdown();}
if (keydown2(keycode(u),true)) {this.wait=0;this.lock = 0;}
if (keydown2(keycode(n),true)) {this.wait=0;this.lock = 1;}
}
}
if (strlen(#s(clientr.playermenu))>0) {
for (i=0; i<sarraylen(clientr.playermenu); i++;) {
showimg 700+i,@#I(clientr.playermenu,i),5,120+(i*15);
changeimgvis 700+i,5;
changeimgzoom 700+i,.75;
changeimgcolors 700+i,this.r,this.g,this.b,this.a;
}
if (keydown2(keycode(h),true)) hidePlayer();
}
this.wait+=2.5;
timeout=.05;
}
function updateDropdown() {
for (i=0; i<sarraylen(this.menuitems); i++;) {
showimg 600+i,@#I(this.menuitems,i),this.x,this.y+(i*15);
changeimgvis 600+i,5;
changeimgzoom 600+i,.75;
changeimgcolors 600+i,this.r,this.g,this.b,this.a;
}
}
function showDropdown() {
this.on = 1;
this.wait=0;
for (i=0; i<sarraylen(this.menuitems); i++;) {
showimg 600+i,@#I(this.menuitems,i),mousescreenx,mousescre eny+(i*15);
changeimgvis 600+i,5;
changeimgzoom 600+i,.75;
changeimgcolors 700+i,this.r,this.g,this.b,this.a;
}
this.x = mousescreenx;
this.y = mousescreeny;
}
function moveDropdown() {
this.wait=0;
for (i=0; i<sarraylen(this.menuitems); i++;) {
showimg 600+i,@#I(this.menuitems,i),this.x,this.y+(i*15);
changeimgvis 600+i,5;
changeimgzoom 600+i,.75;
changeimgcolors 700+i,this.r,this.g,this.b,this.a;
}
}
function hideDropdown() {
this.on = 0;
this.wait=0;
for (i=0; i<sarraylen(this.menuitems); i++;) hideimg 600+i;
}
function getPlayer() {
for (i=0; i<playerscount; i++;) {
if (mousex in |players[i].x, players[i].x+3| && mousey in |players[i].y, players[i].y+4|) setstring this.account,#a(i);
}
triggeraction 0,0,serverside,-playerinfo,getPlayer,#s(this.account);
}
function hidePlayer() {
setstring this.account,;
for (i=0; i<sarraylen(clientr.playermenu); i++) hideimg 700+i;
setstring clientr.playermenu,;
}
if (playerchats) {
if (startswith(/colors,#c)) {
tokenize #c;
setstring client.colors,#t(1) #t(2) #t(3) #t(4);
}
if (strequals(#c,/status-help))
say2 #b
Status System.#b
Commands:#b
Left click - Show your own stats#b
Right click - Hide your stats#b
Mouse Wheel - move your stats#b
Press n - Lock your stats#b
Press u - Unlock your stats#b
Mouseover a player - View his/her#b
stats#b
Press h - Hide their stats#b
More soon!;
}


Projectshifter 05-02-2002 08:22 PM

Sans doesn't have an NPC server :'(
---Shifter

Saga2001 05-02-2002 11:31 PM

Well if you want to see it, go on Andor, and say:
"/status-help"

Saga2001 05-03-2002 10:54 PM

Wow, I am a complete idiot. Why am I going clientside when all that info can be retrived clientside with the players[i].value...Well I'll be working on that, but I think you get the point.

prozac424242 05-03-2002 11:13 PM

simple fun
 
this is not as fancy but its still cool
NPC Code:

// NPC made by Prozac
if (playerenters)
{timeout=.05;}
if (timeout)
{
if (leftmousebutton) {
putexplosion2 3,2,mousex,mousey;
}
timeout=.05;
}



insteat of explosion you can do showimg, lay rupee, putbomb, hitobjecs, .. be creative! heh

prozac424242 05-03-2002 11:16 PM

the move on click
 
Glory. you might wanna add some onwall commands to that script so players cant cheat ... and not move faster than you could walk heh

TDO2000 05-04-2002 01:23 AM

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 ;)

Saga2001 05-04-2002 02:25 AM

Quote:

Originally posted by Kaimetsu
I really want to post my gesture recognition system, but y'know, script stealing and all :(
:-/. A gesture script, what do you mean? :confused: well sounds leet. St00pid script stealers...

Neonight 05-04-2002 01:36 PM


Jagen:
Black and white is pretty leet, too bad people are too indecent and they steal scripts, your script sounds interesting, maybe you should make it like b & w and make it so the color effects only show when you have a valid rune?

Neonight 05-04-2002 01:52 PM

Quote:

Originally posted by Kaimetsu


So how does the player see where he's already drawn? (I've never played B&W, y'see)


Jagen:
In b&w, I think the hand (you, the god) leaves behind a really light trail but when the gesture is valid, it gets a lot brighter and darker, I just remembered that it did leave a slight trail, I had forgotten since I've been letting my cousins rent that game...
Does your gesture system have a write feature? Where you can imput your own gestures? Or did you program specific gestures into the script?

Glory 05-05-2002 08:49 PM

Re: the move on click
 
Quote:

Originally posted by prozac424242
Glory. you might wanna add some onwall commands to that script so players cant cheat ... and not move faster than you could walk heh
I didn't make it.


All times are GMT +2. The time now is 04:13 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.