Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Level transition fade in/out (https://forums.graalonline.com/forums/showthread.php?t=134260559)

Soala 09-17-2010 06:47 PM

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

Deas_Voice 09-17-2010 06:52 PM

cool :cool: :)

MrOmega 09-17-2010 06:58 PM

neato

cbk1994 09-18-2010 12:43 AM

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.

Soala 09-18-2010 12:25 PM

I didn't know about that, so I assume the custom level link could be revised. Thanks for pointing that out :)


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

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