Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-11-2009, 12:32 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
Analog Clock

Graal Script Code:
if (playerenters||timeout) {
  
showimg 0,insom_gui-watch.png,screenwidth-105,0;
  
changeimgvis 0,4;

  
temp.thp=(temp.thp-1)%1201;

  
setarray temp.points,8;

  
temp.cx=screenwidth-52;
  
temp.cy=52;
  
temp.h=30;
  
temp.radian=(pi*temp.thp/50);
  
temp.points[0]=temp.cx+(sin(temp.radian)*4);
  
temp.points[1]=temp.cy+(cos(temp.radian)*4);
  
temp.points[2]=temp.cx-(cos(temp.radian)*1);
  
temp.points[3]=temp.cy+(sin(temp.radian)*1);
  
temp.points[4]=temp.cx-(sin(temp.radian)*temp.h);
  
temp.points[5]=temp.cy-(cos(temp.radian)*temp.h);
  
temp.points[6]=temp.cx+(cos(temp.radian)*1);
  
temp.points[7]=temp.cy-(sin(temp.radian)*1);
  
showpoly 1,temp.points;
  
changeimgvis 1,6;
  
changeimgcolors 1,0.1,0.1,0.1,1;
  
temp.h+=4;
  
temp.points[0]=temp.cx+(sin(temp.radian)*5);
  
temp.points[1]=temp.cy+(cos(temp.radian)*5);
  
temp.points[2]=temp.cx-(cos(temp.radian)*2);
  
temp.points[3]=temp.cy+(sin(temp.radian)*2);
  
temp.points[4]=temp.cx-(sin(temp.radian)*temp.h);
  
temp.points[5]=temp.cy-(cos(temp.radian)*temp.h);
  
temp.points[6]=temp.cx+(cos(temp.radian)*2);
  
temp.points[7]=temp.cy-(sin(temp.radian)*2);
  
showpoly 2,temp.points;
  
changeimgvis 2,5;
  
changeimgcolors 2,0.5,0.5,0.5,0.25;

  
temp.h=20;
  
temp.radian=(pi*temp.thp/600);
  
temp.points[0]=temp.cx+(sin(temp.radian)*4);
  
temp.points[1]=temp.cy+(cos(temp.radian)*4);
  
temp.points[2]=temp.cx-(cos(temp.radian)*2);
  
temp.points[3]=temp.cy+(sin(temp.radian)*2);
  
temp.points[4]=temp.cx-(sin(temp.radian)*temp.h);
  
temp.points[5]=temp.cy-(cos(temp.radian)*temp.h);
  
temp.points[6]=temp.cx+(cos(temp.radian)*2);
  
temp.points[7]=temp.cy-(sin(temp.radian)*2);
  
showpoly 3,temp.points;
  
changeimgvis 3,6;
  
changeimgcolors 3,0.1,0.1,0.1,1;
  
temp.h+=4;
  
temp.points[0]=temp.cx+(sin(temp.radian)*5);
  
temp.points[1]=temp.cy+(cos(temp.radian)*5);
  
temp.points[2]=temp.cx-(cos(temp.radian)*3);
  
temp.points[3]=temp.cy+(sin(temp.radian)*3);
  
temp.points[4]=temp.cx-(sin(temp.radian)*temp.h);
  
temp.points[5]=temp.cy-(cos(temp.radian)*temp.h);
  
temp.points[6]=temp.cx+(cos(temp.radian)*3);
  
temp.points[7]=temp.cy-(sin(temp.radian)*3);
  
showpoly 4,temp.points;
  
changeimgvis 4,5;
  
changeimgcolors 4,0.5,0.5,0.5,0.25;
  
timeout=0.05;

I'm sure a clever coder could make a for loop for the points, but I like it my way. Replace temp.thp with the number of minutes you wish to reflect. Adding a second hand is left as an exercise for the reader. (Hint: You could probably just increment temp.thp by 1/60.)
Attached Images
 
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #2  
Old 03-12-2009, 06:23 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
is this a level npc?
because there would be no reason for posting this in gs1!
nice tho, but i really have to say that i hate your styling..
this.something=1; vs this.something = 1;
and for an example then u do the math,
temp.points[0]=temp.cx+(sin(temp.radian)*4);
just looks awful styling. use some spaces!
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #3  
Old 03-12-2009, 06:28 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Deas_Voice View Post
is this a level npc?
because there would be no reason for posting this in gs1!
nice tho, but i really have to say that i hate your styling..
this.something=1; vs this.something = 1;
and for an example then u do the math,
temp.points[0]=temp.cx+(sin(temp.radian)*4);
just looks awful styling. use some spaces!
It's called personal preference, and every person/scripter is allowed to have their own way of styling.
__________________
Reply With Quote
  #4  
Old 03-12-2009, 06:36 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by Chompy View Post
It's called personal preference, and every person/scripter is allowed to have their own way of styling.
yeah i know that ._.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #5  
Old 03-12-2009, 06:40 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
Yeah, I did the whole damn thing in Offline Scripting. Feel free to convert to GS2 if you like, but I have bad luck trying to put GS2-converted script into ganis...
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #6  
Old 03-13-2009, 02:02 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Pretty inefficient and sore on the eyes. I use this on Maloria, perhaps any of it would make it possible for you to tweak yours?

Graal Script Code:
//#CLIENTSIDE
function onCreated()
{
  
setImg("mal_clock.gif");
  
drawUnderPlayer();
  
setTimer(.05);
}

function 
onTimeOut()
{
  
// Hour
  
with (findImg(200)) {
    
this.angle = -pi*(serverr.time.hour/6);
    
polygon = { 1.9.3*sin(this.angle), .9 .3*cos(this.angle) };
    
red .45green .2blue .1;
    
layer 2;
  }
  
  
// Minute
  
with (findImg(201)) {
    
this.angle = -pi*(serverr.time.minute/30);
    
polygon = { 1.9.5*sin(this.angle), .9 .5*cos(this.angle) };
    
red .3green .2blue .1;
    
layer 2;
  }
  
  
// Second
  
with (findImg(202)) {
    
this.angle = -pi*(serverr.time.second/30);
    
polygon = { 1.9.35*sin(this.angle), .9 .35*cos(this.angle) };
    
red .3green .2blue .1;
    
layer 2;
  }
  
setTimer(.05);
}

function 
onActionDoubleMouse()
{
  
client.messages.add("This is a clock");
  
client.messages.add("The current time is" SPC serverr.time.hour ":" serverr.time.minute);

Attached Images
 
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #7  
Old 03-14-2009, 04:29 AM
ff7chocoboknight2 ff7chocoboknight2 is offline
Skyzer Zolderon
ff7chocoboknight2's Avatar
Join Date: Mar 2009
Location: Hudson, New Hampsire, United States
Posts: 40
ff7chocoboknight2 will become famous soon enough
Send a message via AIM to ff7chocoboknight2 Send a message via MSN to ff7chocoboknight2
This is neat.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:39 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.