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 07-12-2007, 02:01 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
Model Race Timer Script

(... or any other kind of time challenge script, given various changes)

Another thing that I wanted to do was create quests and stuff. In Graal, quests are synonomous with mundane crap like "go deliver this letter" or "go kill this monster in a tower" and I wanted to make stuff that I usually see in other RPG games — not anything specific, mind you, but general models of quests that I've never seen on any server. I'm not talented at creating puzzles or whatever, and I'm sure you're better than me at it so blah. With this Race thing, I was thinking that races could be used in a quest somehow — how exactly, I forget to be honest.

Attached is the level file in which the script is put to use — feel free to download, but don't count on it working unless you have a server to upload and warp to.

To keep in line with my habits of explaining things, I'll elaborate on the concept and how it works.

The level contains three main NPCs: The Goal line (for counting laps), the Block (as in most race events on servers, there's a wall or something to prevent the players from crossing the line to start so they're all together and start even), and the Timer. The commands for start and end are pretty self-explanatory: /go and /stop. Make sure you're on the right side of the goal line before you begin since the 'block' is on the right side.

The timer is probably the most important part of the script. It is made for just use in that one level, but I'm sure you can figure out how to make it work outside of the level later on. It's very simple. this.t0 and this.t1 mean beginning and ending times, and are used to get the final time.

It's stupidly easy to make a countdown script ("do this in 5 seconds or you lose!") for a quest or puzzle, but perhaps you can use this for a race event to keep track of fastest record times (horse race???).



PS -- in case for whatever reason you can't download the .nw, here are the three scripts themselves. I'm sure you can figure out how to use them.
PHP Code:
//#CLIENTSIDE
//"The Goal Line"
function onCreated() {
  
setshape(1,16,16*6);
  
dontblock();
  
drawunderplayer();
}
function 
onPlayerenters() {
  
finish();
}
function 
onPlayerleaves() {
  
finish();
}
function 
onPlayertouchsme() {
  if (
client.questxRACE>0) {
    if (
this.lap<3) {
      
this.lap++;
      if (
this.lap==3) { chat "Final lap!"; }
      else { 
chat "Lap" SPC this.lap "!"; }
    } else { 
finish(); }
  }
}
function 
finish() {
  
client.questxRACE null;
  
this.lap null;
  
chat "say /go to begin; /stop to end if you cannot do the 3 laps";

PHP Code:
//#CLIENTSIDE
//"The Block"
function onCreated() {
  
setshape(1,16,16*6);
  
blockagain();
}
function 
onPlayerchats() {
  if (
player.chat=="/go") {
    
client.questxRACE 1;
    
hide();
  }
  if (
player.chat=="/stop") {
    
client.questxRACE null;
    
show();
  }
}
function 
onPlayerenters() { this.setTimer(.1); }
function 
onTimeout() {
  if (
client.questxRACE in {null,0}) {
    
show();
    
this.setTimer(0);
  }
  
this.setTimer(.2);

PHP Code:
//#CLIENTSIDE
//The "timer"
function onPlayerenters() {
  
client.questxRACE this.t0 this.t1 null;
  
this.setTimer(.05);
}
function 
onPlayerleaves() {
  
client.questxRACE null;
}
function 
onTimeout() {
  if (
client.questxRACE>0) {
    
this.t0 timevar2;
    
this.t1 0this.t1 += .1;
    
chat this.t1;
  } else if (
this.t1>|| this.t0>0) {
    
chat "Your Final Time:" SPC abs((this.t1+this.t0)-this.t0);
    if (
client.questxRACErecord in {null,0}) {
      
client.questxRACErecord 318;
    }
    if (
abs((this.t1+this.t0)-this.t0)<client.questxRACErecord) {
      
client.questxRACErecord abs((this.t1+this.t0)-this.t0);
    }
    
this.t1 this.t0 null;
  }
  
this.setTimer(.05);

Attached Files
File Type: nw questx_racepuzzle.nw (10.9 KB, 199 views)
Reply With Quote
  #2  
Old 07-12-2007, 02:07 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Upon quickly looking at the scripts themselves, I get the feeling that it could have been done alot smoother.. the scripts come off as sloppy to me. But hey, that's just my initial thoughts.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 07-13-2007, 12:23 AM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
It was something I was working on just before I left, and I didn't give myself too much time with it all. I had modeled it after the events i had done, so if there is a better way of doing the race, feel free and i'll replace it
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 01:06 AM.


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