Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-17-2010, 06:47 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Level transition fade in/out

You probably went on Ruins lately, and saw the level transition effects (fade in/out). A lot of people are asking me how it was made, so I decided to simply share it. Might be useful for people later on!

Class (named level_link)
PHP Code:
function onCreated() {
  
this.setshape(1this.w*16this.h*16);
  
this.blockagain();
}

//#CLIENTSIDE
function onCreated() {
  
this.setshape(1this.w*16this.h*16);
  
this.blockagain();
}

function 
onPlayerTouchsMe() {
  if (
this.touched) return;
  
temp.data = {this.lvlthis.lvlxthis.lvly};
  
interfaceVisuals.fadelevel(temp.data);
  
this.touched true;
  
setTimer(3);
}

function 
onTimeout()
  
this.touched false
interfaceVisuals is our wNPC handling all the visuals, along with the fade in/out effects, here are the bits of it for the fade effect
PHP Code:
public function fadelevel(lvldata) {
  
client.freezed true;
  
fadeOut(lvldata);
}
  

function 
fadeIn() {
  for(
temp.1temp.>= -0.30temp.-= 0.30) {
    
findimg(this.poly).alpha temp.i;
    
sleep(0.05);
  }
  
hideimg(this.poly);
  
this.poly 0;
  
client.freezed false;
}

function 
fadeOut(lvldata) {
  
temp.data lvldata;
  
client.warpdata lvldata;
  if (
this.poly == 0this.poly drawScreenPoly(); 
  for(
temp.0temp.1.35temp.+= 0.35) {
    
findimg(this.poly).alpha temp.i;
    
sleep(0.05);
  }
  
setani("your idle gani name"0);
  
sleep(0.25);
  
triggerserver("gui""interfaceVisuals""warpplayer"0);
  
sleep(0.5);
  
fadeIn();


Here's an example of level npc you can use in order to use the link and level transition:
PHP Code:
this.join("level_link");
this.6;
this.1;
//#CLIENTSIDE
this.6;
this.1;
this.lvl "level name it links to.nw";
this.lvlx 24;
this.lvly 1
this.w is the link's width and this.h the link's height (in tiles of course)

Credits to Axel (account: Contrast, go +rep him if you want!) for making it, and to Tig who gave us some hints on how GK's was made. Enjoy

Last edited by Soala; 09-17-2010 at 07:15 PM..
Reply With Quote
  #2  
Old 09-17-2010, 06:52 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
cool
__________________
.
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 09-17-2010, 06:58 PM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
neato
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #4  
Old 09-18-2010, 12:43 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Please, please, please don't do this.
PHP Code:
this.join("level_link");
this.6;
this.1;
//#CLIENTSIDE
this.6;
this.1;
this.lvl "level name it links to.nw";
this.lvlx 24;
this.lvly 1
This is so much nicer and far preferable:

PHP Code:
function onCreated() {
  
this.join("level_link");
  
this.6;
  
this.1;
}
//#CLIENTSIDE
function onCreated() {
  
this.6;
  
this.1;
  
this.lvl "level name it links to.nw";
  
this.lvlx 24;
  
this.lvly 1;

Also, your weapon script is extremely insecure. If that script is in use, I could easily warp to any level on Ruins with Cheat Engine. Heck, it's less secure than traditional links. The server should never accept data from the client (such as a level name).

I would probably do it like so (unimportant parts omitted):

PHP Code:
// link class
function onCreated() {
  
// establish a way to refer to it via coordinates serverside
  
this.level.link.(@ this.x  "_" this.y) = this;
}

//#CLIENTSIDE
function onPlayerTouchsMe() {
  
// setup the x,y so the server can find the link
  
interfaceVisuals.trigger("touchLevelLink"this);

and in the link weapon (fading bits omitted):

PHP Code:
function onActionServerSide(cmddata) {
  if (
cmd == "warp") {
    
// find the relevant link
    
temp.link player.level.link.(@ data[0] @ "_" data[1]);
    
    if (
link.lvl == null) {
      
// level not defined
      
return;
    }
    
    
// check if the player's x/y are in the link
    
if (! (player.x in |link.xlink.width|) || ! (player.y in |link.ylink.height|)) {
      return; 
// this might need some tweaking
    
}
    
    
player.setLevel2(link.lvllink.warpxlink.warpy;
  }
}

//#CLIENTSIDE
function onTouchLevelLink(link) {
  
// it's preferable to pass data as parameters rather than client. variables
  
triggerServer("gui"this.name"warp", {link.xlink.y});

Since the level data would be stored serverside instead of clientside there's no chance that the client can manipulate them to warp to any level except the level you've defined.
__________________
Reply With Quote
  #5  
Old 09-18-2010, 12:25 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
I didn't know about that, so I assume the custom level link could be revised. Thanks for pointing that out
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 07:20 PM.


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