Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Somersaults (dodge) (https://forums.graalonline.com/forums/showthread.php?t=134267633)

papajchris 12-24-2012 05:42 PM

I accept you for who you are

Trakan 12-24-2012 06:48 PM

Thanks dude xD

Okay i now have:

PHP Code:

// Scripted by *Trakan
//#CLIENTSIDE
function onKeyPressed(keyCodekeyNamescanCode) {
  if (
keyName == "e") {
    if (
player.dir == && !indodge) {
      
freezeplayer(1.5);
      
setani gh_gani_roulade, ;
      
set indodge;
      for (
temp.0temp.4temp.i++) {
        
player.+= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani idle, ;
    }
    if (
player.dir == && !indodge) {
      
freezeplayer(1.5);
      
setani gh_gani_roulade, ;
      
set indodge;
      for (
temp.0temp.4temp.i++) {
        
player.-= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani idle, ;
    }
    if (
player.dir == && !indodge) {
      
freezeplayer(1.5);
      
setani gh_gani_roulade, ;
      
set indodge;
      for (
temp.0temp.4temp.i++) {
        
player.-= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani idle, ;
    }

  if (
player.dir == && !indodge) {
    
freezeplayer(1.5);
    
setani gh_gani_roulade, ;
    
set indodge;
    for (
temp.0temp.4temp.i++) {
      
player.+= 1;
      
sleep(.1);
    }
    
sleep(0.5);
    unset 
indodge;
    
setani idle, ;
  }
}


It's work fine! But.. players can go in blocking tiles as i say before. How can I select the tiles that I do not want the player went on?

Gunderak 12-25-2012 12:24 AM

Quote:

Originally Posted by Crow (Post 1710438)
I wonder why :noob:

What? O_o

And as for blocking tiles.
PHP Code:

  tiles[xy]; 


callimuc 12-25-2012 12:44 AM

Quote:

Originally Posted by Gunderak (Post 1710501)
And as for blocking tiles.
PHP Code:

  tiles[xy]; 


so you expect him to write down all blocking tiles while he could do a simple onwall(), onwall2() or tiletype() check?

Quote:

Originally Posted by Trakan (Post 1710468)
Thanks dude xD

Okay i now have:

PHP Code:

// Scripted by *Trakan
//#CLIENTSIDE
function onKeyPressed(keyCodekeyNamescanCode) {
  if (
keyName == "e") {
    if (
player.dir == && !indodge) {
      
freezeplayer(1.5);
      
setani gh_gani_roulade, ;
      
set indodge;
      for (
temp.0temp.4temp.i++) {
        
player.+= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani idle, ;
    }
    if (
player.dir == && !indodge) {
      
freezeplayer(1.5);
      
setani gh_gani_roulade, ;
      
set indodge;
      for (
temp.0temp.4temp.i++) {
        
player.-= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani idle, ;
    }
    if (
player.dir == && !indodge) {
      
freezeplayer(1.5);
      
setani gh_gani_roulade, ;
      
set indodge;
      for (
temp.0temp.4temp.i++) {
        
player.-= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani idle, ;
    }

  if (
player.dir == && !indodge) {
    
freezeplayer(1.5);
    
setani gh_gani_roulade, ;
    
set indodge;
    for (
temp.0temp.4temp.i++) {
      
player.+= 1;
      
sleep(.1);
    }
    
sleep(0.5);
    unset 
indodge;
    
setani idle, ;
  }
}



things you should fix:
PHP Code:

setani("ani"params); //proper gs2; if you dont have params make it NULL (params part)

this.indodge boolean//boolean is true or false; should be used instead of using (un)set

for (temp.0temp.4temp.i++) {
  if (
onwall2(player.x+0.5player.y+1+122)) continue;
  
//onwall2(x, y, width, height);
  //at the player.y part i added two +1 because the first is to have it go down to the "default" block check and the
  //2nd one is for the new y position, personal reference of doing it like this; should be fixed with '-' or at the
  //'player.x' parts when you are using it in other directions
  //continue should make it leave the for() loop when you are on the wall (regarding the check)

  
player.+= 1;
  
sleep(.1);



Trakan 12-25-2012 12:09 PM

Now go this, is it good?
PHP Code:

// Scripted by *Trakan
//#CLIENTSIDE
function onKeyPressed(keyCodekeyNamescanCode) {
  if (
keyName == "e") {
    if (
player.dir == && !indodge) {
      
freezeplayer(0.8);
      
setani("gh_gani_roulade"NULL);
      
set indodge;
for (
temp.0temp.4temp.i++) {
  if (
onwall2(player.x+0.5player.y+1+122)) continue;
        
player.+= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani("idle"NULL);
    }
    if (
player.dir == && !indodge) {
      
freezeplayer(0.8);
      
setani("gh_gani_roulade"NULL);
      
set indodge;
      for (
temp.0temp.4temp.i++) {
      if (
onwall2(player.x+0.5player.y+1+122)) continue;
        
player.-= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani("idle"NULL);
    }
    if (
player.dir == && !indodge) {
      
freezeplayer(0.8);
      
setani("gh_gani_roulade"NULL);
      
set indodge;
      for (
temp.0temp.4temp.i++) {
      if (
onwall2(player.x-0.5player.y-1-122)) continue;
        
player.-= 1;
        
sleep(.1);
      }
      
sleep(0.5);
      unset 
indodge;
      
setani("idle"NULL);
    }

  if (
player.dir == && !indodge) {
    
freezeplayer(0.8);
      
setani("gh_gani_roulade"NULL);
    
set indodge;
    for (
temp.0temp.4temp.i++) {
    if (
onwall2(player.x-0.5player.y-1-122)) continue;
      
player.+= 1;
      
sleep(.1);
    }
    
sleep(0.5);
    unset 
indodge;
    
setani("idle"NULL);
  }
}



Gunderak 12-25-2012 12:13 PM

Quote:

Originally Posted by callimuc (Post 1710503)
so you expect him to write down all blocking tiles while he could do a simple onwall(), onwall2() or tiletype() check?



things you should fix:
PHP Code:

setani("ani"params); //proper gs2; if you dont have params make it NULL (params part)

this.indodge boolean//boolean is true or false; should be used instead of using (un)set

for (temp.0temp.4temp.i++) {
  if (
onwall2(player.x+0.5player.y+1+122)) continue;
  
//onwall2(x, y, width, height);
  //at the player.y part i added two +1 because the first is to have it go down to the "default" block check and the
  //2nd one is for the new y position, personal reference of doing it like this; should be fixed with '-' or at the
  //'player.x' parts when you are using it in other directions
  //continue should make it leave the for() loop when you are on the wall (regarding the check)

  
player.+= 1;
  
sleep(.1);



Whatever.
There are many ways of achieving the same thing.
I was simply providing one.

Trakan 12-25-2012 12:37 PM

I have a little problem, when i dodge up and down, it's not working very well

MysticalDragon 12-25-2012 03:16 PM

Quote:

Originally Posted by Gunderak (Post 1710428)
I think this ends now.
Reborn is frowned upon.
Good day to you.

Although I dislike reborn, I respect what they did. Instead of Lurking around the forums crying about how graal is they did something about it.

On Topic,
Don't use unset indodge its deprecated. Use temp Variables like Callimuc suggested.

xAndrewx 12-26-2012 12:54 PM

HTML Code:

function onKeyPressed(keyCode, keyName, scanCode) {
  if (keyName != "e") return;
  if (this.inMotion) return;

  this.inMotion = true;
  player.ani = "gh_gani_roulade";
  for (temp.i = 0; temp.i < 3; temp.i++) {
    if (onwall2(player.x + (vecx(player.dir)*1.5), player.y + (vecy(player.dir)*1.5), 2, 2)) break;

    if (player.dir in {1, 3}) player.x += vecx(player.dir)*1.5;
    else if (player.dir in {0, 2}) player.y += vecy(player.dir)*1.5;
    sleep(0.05);
  }
  this.inMotion = false;
  player.ani = "idle"; 
}

Should work in all directions.
Look up VECX and VECY - everything else is straight forward

Trakan 12-26-2012 01:19 PM

Quote:

Originally Posted by xAndrewx (Post 1710618)
HTML Code:

function onKeyPressed(keyCode, keyName, scanCode) {
  if (keyName != "e") return;
  if (this.inMotion) return;

  this.inMotion = true;
  player.ani = "gh_gani_roulade";
  for (temp.i = 0; temp.i < 3; temp.i++) {
    if (onwall2(player.x + (vecx(player.dir)*1.5), player.y + (vecy(player.dir)*1.5), 2, 2)) break;

    if (player.dir in {1, 3}) player.x += vecx(player.dir)*1.5;
    else if (player.dir in {0, 2}) player.y += vecy(player.dir)*1.5;
    sleep(0.05);
  }
  this.inMotion = false;
  player.ani = "idle"; 
}

Should work in all directions.
Look up VECX and VECY - everything else is straight forward

Thanks! It work fine but it does not look like realist because there are not the sleep(.1); ect... I try to fix that

EDIT: fixed, thanks dude :)

EDIT2: @xAndrewx: I don't know where i put the freezeplayer xD

cbk1994 12-26-2012 02:29 PM

Keep in mind that setting player.ani the way Andy does is only supported on v6 and above.


All times are GMT +2. The time now is 09:35 AM.

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