Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   ladder script (https://forums.graalonline.com/forums/showthread.php?t=134261084)

callimuc 11-13-2010 10:52 PM

ladder script
 
hey i´m new in this forum and also got a question now xD

so how can i make a ladder script on playerworld? like:

function onPlayertouchsme () {
setani anifile,;
and here that the player will move up to the y1 <-> y2 i want
}


anyone can help me?:confused::confused:

MrOmega 11-14-2010 12:25 AM

PHP Code:

//#CLIENTSIDE

function onCreated()
{

  
this.ladderImg = <ladderIMG>; // Replace <ladderIMG> with the ladder image you want to use surrounded by quotes
  
this.ladderIdle = <ladderANIidle>; // Replace <ladderANIidle> with the idle ladder gani you want to use, surrounded by quotes
  
this.ladderWalk = <ladderANIwalk>; // Replace <ladderANIwalk> with the walk/moving ladder gani you want to use, surrounded by quotes

  
setImgthis.ladderImg); // Sets the ladder image
  
setshape1getimgwidththis.ladderImg), getimgheightthis.ladderImg)); // This sets the shape of the ladder so the client can detect it better in my opinion

  
onTimeout(); // This will start the onTimeout Loop

}

function 
onTimeout()
{

  if ( 
player.1.5 in this.xthis.+ (  getimgwidththis.ladderImg) / 16)| &&
       
player.2.0 in this.ythis.+ ( getimgheightthis.ladderImg) / 16)|) // Checks to see if the player is on the ladder
  
{
 
    
player.onLadder true// We'll set this flag so we can know later on that the player is on the ladder
    
setanithis.ladderIdleNULL); // Sets the players gani to the idle ladder gani
    //You could also do player.dir = 0; and not use special ganis altogether, just us 'idle' and 'walk' (or 'walkslow')

  
}

  else
    
player.onLadder false// This tells the script later on that the player is NOT on the ladder

  
if ( player.onLadder// You don't have to do '== true' cause the if statement already checks if it's true or false
  
{

    
disableDefMovement(); // Disables the defualt Movement system so we can control the player's movement

    
for ( temp.0temp.4temp.+= 2)  // Cycles though the up and down arrow keycodes ( 0 - up, 2 - Down)
    
{

      if ( 
keydowntemp.k)) //If player pushes an arrow key this will catch it
      
{

        
setanithis.ladderWalkNULL): // Sets the players gani to the walking/moving ladder gani 
        
player.+= vecytemp.k) * 0.35// Moves the players Y coor only, 0.35 is the speed, normal speed is 0.5 or 8 pixels every 0.05 seconds
        // Vecy will return -1, 0, or 1. If temp.k is 0 then it will give -1, if temp.k is 1 or 3 it will give 0, If it's 2 then it will return 1

      
}
    }
  }

  else 
// This will be called when player.onLadder is false
    
enableDefMovement(); // Enables the default movement system, so the player can move normally again

  
setTimer0.05); // Will call onTimeout in 0.05 seconds




DustyPorViva 11-14-2010 12:34 AM

Ladders would be a lot easier if setshape2 allowed you to overwrite blocking tiles with nonblocking.

MrOmega 11-14-2010 12:42 AM

Quote:

Originally Posted by DustyPorViva (Post 1611688)
Ladders would be a lot easier if setshape2 allowed you to overwrite blocking tiles with nonblocking.

Yep, but we gotta make do with what we got.

xXziroXx 11-14-2010 01:37 AM

I would personally attach the player to the ladder, slow his/her movement speed while attached and then work from there.

callimuc 11-14-2010 03:09 AM

thx MrOmega. it worked except one little thing: when i climb it uses the idle. but when i stop climbing on ladder its fine (so i didnt mix up)

MrOmega 11-14-2010 06:16 AM

Are this.ladderIdle and this.ladderWalk different ganis?

callimuc 11-14-2010 06:12 PM

yes they are


All times are GMT +2. The time now is 03:33 PM.

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